Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load extension modules from top-level #75

Merged
merged 1 commit into from
Jul 4, 2017

Conversation

eagletmt
Copy link
Member

@eagletmt eagletmt commented Jul 4, 2017

Module.const_get(name, false) returns Module::name, which isn't
intended name for extension modules.
The reason why Module.const_get('DummyExtension', false) is working in
test environment is that Module.const_get('DummyExtension', false)
invokes autoloading by AS::Dependencies and finds
spec/dummy/lib/dummy_extension.rb and returns DummyExtension in
despite of Module namespace. In this case, the first call of
Module.const_get('DummyExtension', false) returns DummyExtension,
but raises NameError: uninitialized constant Module::DummyExtension
afterward.

Module.const_get('DummyExtension', false) # Return DummyExtension
Module.const_get('DummyExtension', false) # Raise NameError

@eisuke @cookpad/dev-infra please review

`Module.const_get(name, false)` returns `Module::name`, which isn't
intended name for extension modules.
The reason why `Module.const_get('DummyExtension', false)` is working in
test environment is that `Module.const_get('DummyExtension', false)`
invokes autoloading by AS::Dependencies and finds
spec/dummy/lib/dummy_extension.rb and returns `DummyExtension` in
despite of `Module` namespace. In this case, the first call of
`Module.const_get('DummyExtension', false)` returns `DummyExtension`,
but raises `NameError: uninitialized constant Module::DummyExtension`
afterward.

```ruby
Module.const_get('DummyExtension', false) # Return DummyExtension
Module.const_get('DummyExtension', false) # Raise NameError
```
@eagletmt eagletmt merged commit 2d9e119 into cookpad:master Jul 4, 2017
@eagletmt eagletmt deleted the load-from-toplevel branch July 4, 2017 03:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants