Class: Tapioca::Compilers::Dsl::UrlHelpers
- Inherits:
-
Base
- Object
- Base
- Tapioca::Compilers::Dsl::UrlHelpers
show all
- Extended by:
- T::Sig
- Defined in:
- lib/tapioca/compilers/dsl/url_helpers.rb
Constant Summary
collapse
- NON_DISCOVERABLE_INCLUDERS =
T.let([
ActionDispatch::IntegrationTest,
ActionView::Helpers,
], T::Array[Module])
Instance Attribute Summary
Attributes inherited from Base
#processable_constants
Instance Method Summary
collapse
Methods inherited from Base
#handles?, #initialize
Instance Method Details
#decorate(root, constant) ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/tapioca/compilers/dsl/url_helpers.rb', line 21
def decorate(root, constant)
case constant
when GeneratedPathHelpersModule.singleton_class, GeneratedUrlHelpersModule.singleton_class
generate_module_for(root, constant)
else
root.path(constant) do |mod|
create_mixins_for(mod, constant, GeneratedUrlHelpersModule)
create_mixins_for(mod, constant, GeneratedPathHelpersModule)
end
end
end
|
#gather_constants ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/tapioca/compilers/dsl/url_helpers.rb', line 39
def gather_constants
Object.const_set(:GeneratedUrlHelpersModule, Rails.application.routes.named_routes.url_helpers_module)
Object.const_set(:GeneratedPathHelpersModule, Rails.application.routes.named_routes.path_helpers_module)
module_enumerator = T.cast(ObjectSpace.each_object(Module), T::Enumerator[Module])
constants = module_enumerator.select do |mod|
next unless Module.instance_method(:name).bind(mod).call
includes_helper?(mod, GeneratedUrlHelpersModule) ||
includes_helper?(mod, GeneratedPathHelpersModule) ||
includes_helper?(mod.singleton_class, GeneratedUrlHelpersModule) ||
includes_helper?(mod.singleton_class, GeneratedPathHelpersModule)
end
constants.concat(NON_DISCOVERABLE_INCLUDERS)
end
|