Sha256: cc8590e3b7348979ba7d9992d8b3e429e887adfeac816cd9b690f3cebcec6b37

Contents?: true

Size: 634 Bytes

Versions: 1

Compression:

Stored size: 634 Bytes

Contents

# frozen_string_literal: true

require 'roda/endpoints/endpoint/singleton'
require 'forwardable'

class Roda
  module Endpoints
    class Endpoint
      # HTTP endpoint representing a specific item of collection uniquely
      # identified by some parameter.
      class Item < Singleton
        extend Forwardable

        # @return [Endpoint::Collection]
        def collection
          parent
        end

        # @!method id
        #   @return [Integer]
        id_proc do
          instance_variable_defined?(:@id) ? @id : captures.last
        end

        def_delegator :collection, :repository
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
roda-endpoints-0.3.6 lib/roda/endpoints/endpoint/item.rb