Module: Tapioca::Gemfile::AutoRequireHook
- Extended by:
- T::Helpers, T::Sig
- Defined in:
- lib/tapioca/gemfile.rb
Overview
This is a module that gets prepended to ‘Bundler::Dependency` and makes sure even gems marked as `require: false` are required during `Bundler.require`.
Class Attribute Summary collapse
-
.exclude ⇒ Object
writeonly
Sets the attribute exclude.
Class Method Summary collapse
Instance Method Summary collapse
Class Attribute Details
.exclude=(value) ⇒ Object (writeonly)
Sets the attribute exclude
30 31 32 |
# File 'lib/tapioca/gemfile.rb', line 30 def exclude=(value) @exclude = value end |
Class Method Details
.excluded?(name) ⇒ Boolean
33 34 35 |
# File 'lib/tapioca/gemfile.rb', line 33 def excluded?(name) @exclude.include?(name) end |
Instance Method Details
#autorequire ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/tapioca/gemfile.rb', line 39 def autorequire value = super # If the gem is excluded, we don't want to force require it, in case # it has side-effects users don't want. For example, `fakefs` gem, if # loaded, takes over filesystem operations. return value if AutoRequireHook.excluded?(name) # If a gem is marked as `require: false`, then its `autorequire` # value will be `[]`. But, we want those gems to be loaded for our # purposes as well, so we return `nil` in those cases, instead, which # means `require: true`. return nil if value == [] value end |