Class: Cohabit::RouteHelperScope

Inherits:
Object
  • Object
show all
Includes:
Configuration::Settings
Defined in:
lib/cohabit/route_helper_scope.rb

Constant Summary

Constants included from Configuration::Settings

Configuration::Settings::CUSTOM_HANDLERS, Configuration::Settings::DEFAULT_SETTINGS

Instance Attribute Summary

Attributes included from Configuration::Settings

#settings

Instance Method Summary collapse

Methods included from Configuration::Settings

#generate_settings_hash!, included, #initialize_with_settings, #merge_settings!, #set, #set_globals

Constructor Details

#initialize(*args) ⇒ RouteHelperScope

Returns a new instance of RouteHelperScope.



4
5
6
# File 'lib/cohabit/route_helper_scope.rb', line 4

def initialize(*args)
  merge_settings!(args.last) if args.last.is_a?(Hash)
end

Instance Method Details

#apply!(context) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/cohabit/route_helper_scope.rb', line 10

def apply!(context)
  named_routes = get_route_helpers

  route_helpers = Module.new
  route_helpers.module_exec(named_routes, @settings[:association], &route_override_proc)
  Cohabit.const_set("RouteHelpers", route_helpers)
  ActionView::Base.send :include, Cohabit::RouteHelpers
end