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
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
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/tapioca/compilers/dsl/url_helpers.rb', line 20
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/tapioca/compilers/dsl/url_helpers.rb', line 33
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)
constants = ObjectSpace.each_object(Module).select do |mod|
mod = T.cast(mod, T.class_of(Module))
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 << ActionDispatch::IntegrationTest
end
|