Class: UtopiaData::Router

Inherits:
Object
  • Object
show all
Defined in:
lib/utopia_data/router.rb

Instance Method Summary collapse

Constructor Details

#initialize(application) ⇒ Router

Returns a new instance of Router.



24
25
26
# File 'lib/utopia_data/router.rb', line 24

def initialize(application)
  @application = application
end

Instance Method Details

#apply(router) ⇒ Object



28
29
30
31
32
33
34
35
36
37
# File 'lib/utopia_data/router.rb', line 28

def apply(router)
  router.instance_exec(@application.resources) do |resources|
    resources.each do |k, config|
      route_definition_block = Proc.new do
        resources config.resource_name.route_key, :only => [:index, :show]
      end
      instance_eval &route_definition_block
    end
  end
end