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-0.3.2 lib/orange-core/resources/routable_resource.rb
orange-0.3.1 lib/orange-core/resources/routable_resource.rb
orange-0.3.0 lib/orange-core/resources/routable_resource.rb
orange-0.2.11 lib/orange-core/resources/routable_resource.rb
orange-0.2.9 lib/orange-core/resources/routable_resource.rb
orange-0.2.8 lib/orange-core/resources/routable_resource.rb
orange-0.2.7 lib/orange-core/resources/routable_resource.rb
orange-0.2.6 lib/orange-core/resources/routable_resource.rb
orange-0.2.5 lib/orange-core/resources/routable_resource.rb
orange-0.2.4 lib/orange-core/resources/routable_resource.rb
orange-0.2.3 lib/orange-core/resources/routable_resource.rb
orange-0.1.10 lib/orange-core/resources/routable_resource.rb
orange-0.1.8 lib/orange-core/resources/routable_resource.rb
orange-0.1.7 lib/orange-core/resources/routable_resource.rb
orange-0.1.4 lib/orange-core/resources/routable_resource.rb
orange-0.1.2 lib/orange-core/resources/routable_resource.rb
orange-0.1.0 lib/orange-core/resources/routable_resource.rb
orange-0.0.15 lib/orange-core/resources/routable_resource.rb
orange-0.0.14 lib/orange-core/resources/routable_resource.rb