lib/roda/endpoints/endpoint/item.rb in roda-endpoints-0.2.0 vs lib/roda/endpoints/endpoint/item.rb in roda-endpoints-0.3.0
- old
+ new
@@ -1,16 +1,19 @@
# frozen_string_literal: true
require 'roda/endpoints/endpoint/singleton'
require 'roda/endpoints/endpoint/data'
+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
+
prepend Data
self.attributes += %i(id by on)
self.defaults = defaults.merge(
by: :fetch,
@@ -21,16 +24,18 @@
# @return [Symbol]
attr_reader :by
# @return [Integer]
def id
- captures.first
+ @id ||= captures.first
end
# @return [Endpoint::Collection]
def collection
parent
end
+
+ def_delegator :collection, :repository
end
end
end
end