Class: Orange::RoutableResource

Inherits:
Resource show all
Defined in:
lib/orange-core/resources/routable_resource.rb

Direct Known Subclasses

ModelResource

Instance Method Summary collapse

Methods inherited from Resource

#afterLoad, call_me, #do_view, #find_extras, #init, #initialize, #options, #orange, #orange_name, #set_orange, set_orange, #view, #view_opts

Methods included from ClassInheritableAttributes

#cattr_accessor, #cattr_reader, #cattr_writer, eval_in_accessor_module, fetch_value, store_value

Constructor Details

This class inherits a constructor from Orange::Resource

Instance Method Details

#routableObject



5
# File 'lib/orange-core/resources/routable_resource.rb', line 5

def routable; true; end

#route(path, packet) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/orange-core/resources/routable_resource.rb', line 7

def route(path, packet)
  parts = path.split('/')
  first = parts[0].respond_to?(:to_sym) ? parts.shift.to_sym : :index
  new_path = parts.join('/')
  if self.respond_to?(first)
    packet[:content] = self.__send__(first, new_path, packet)
  end
end