Sha256: 3551794fb8b140220217684360251850ec855fa42b56198c0ae61a4503653c8e

Contents?: true

Size: 406 Bytes

Versions: 39

Compression:

Stored size: 406 Bytes

Contents

require 'orange-core/resource'

module Orange
  class RoutableResource < Resource
    def routable; true; end
    
    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
  end
end

Version data entries

39 entries across 39 versions & 2 rubygems

Version Path
orange-core-0.7.1 lib/orange-core/resources/routable_resource.rb
orange-core-0.7.0 lib/orange-core/resources/routable_resource.rb
orange-core-0.6.0 lib/orange-core/resources/routable_resource.rb
orange-core-0.5.9 lib/orange-core/resources/routable_resource.rb
orange-core-0.5.8 lib/orange-core/resources/routable_resource.rb
orange-core-0.5.5 lib/orange-core/resources/routable_resource.rb
orange-core-0.5.3 lib/orange-core/resources/routable_resource.rb
orange-0.5.5 lib/orange-core/resources/routable_resource.rb
orange-0.5.4 lib/orange-core/resources/routable_resource.rb
orange-0.5.3 lib/orange-core/resources/routable_resource.rb
orange-0.5.2 lib/orange-core/resources/routable_resource.rb
orange-0.5.1 lib/orange-core/resources/routable_resource.rb
orange-0.4.0 lib/orange-core/resources/routable_resource.rb
orange-0.3.9 lib/orange-core/resources/routable_resource.rb
orange-0.3.8 lib/orange-core/resources/routable_resource.rb
orange-0.3.7 lib/orange-core/resources/routable_resource.rb
orange-0.3.6 lib/orange-core/resources/routable_resource.rb
orange-0.3.5 lib/orange-core/resources/routable_resource.rb
orange-0.3.4 lib/orange-core/resources/routable_resource.rb
orange-0.3.3 lib/orange-core/resources/routable_resource.rb