Class: Mack::Routes::ResourceProxy
- Defined in:
- lib/mack/routing/resource_proxy.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#controller ⇒ Object
Returns the value of attribute controller.
-
#resources ⇒ Object
Returns the value of attribute resources.
-
#routes ⇒ Object
Returns the value of attribute routes.
Instance Method Summary collapse
-
#initialize(controller, resources = []) ⇒ ResourceProxy
constructor
A new instance of ResourceProxy.
- #method_missing(sym, *args) ⇒ Object
- #resource(name, options = {}, &block) ⇒ Object
Constructor Details
#initialize(controller, resources = []) ⇒ ResourceProxy
Returns a new instance of ResourceProxy.
11 12 13 14 15 |
# File 'lib/mack/routing/resource_proxy.rb', line 11 def initialize(controller, resources = []) self.controller = controller self.routes = [] self.resources = resources end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args) ⇒ Object
17 18 19 |
# File 'lib/mack/routing/resource_proxy.rb', line 17 def method_missing(sym, *args) connect(sym, *args) end |
Instance Attribute Details
#controller ⇒ Object
Returns the value of attribute controller.
7 8 9 |
# File 'lib/mack/routing/resource_proxy.rb', line 7 def controller @controller end |
#resources ⇒ Object
Returns the value of attribute resources.
9 10 11 |
# File 'lib/mack/routing/resource_proxy.rb', line 9 def resources @resources end |
#routes ⇒ Object
Returns the value of attribute routes.
8 9 10 |
# File 'lib/mack/routing/resource_proxy.rb', line 8 def routes @routes end |
Instance Method Details
#resource(name, options = {}, &block) ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/mack/routing/resource_proxy.rb', line 21 def resource(name, = {}, &block) if block_given? proxy = Mack::Routes::ResourceProxy.new(name, [self.resources, name].flatten) yield proxy proxy.routes.each do |route| Mack::Routes::RouteMap.instance.connect_with_name("#{name}_#{route[:name]}", route[:path], .merge(route[:options])) end end Mack::Routes::RouteMap.instance.build_resource_routes(name, compile_path(name, self.resources), name, ) end |