lib/hyperclient/resource.rb in hyperclient-0.2.0 vs lib/hyperclient/resource.rb in hyperclient-0.3.0

- old
+ new

@@ -17,25 +17,30 @@ # Public: Returns the embedded resource of the Resource as a # ResourceCollection. attr_reader :embedded # Public: Delegate all HTTP methods (get, post, put, delete, options and - # head) to its Link. + # head) to its self link. def_delegators :self_link, :get, :post, :put, :delete, :options, :head # Public: Initializes a Resource. + # # representation - The hash with the HAL representation of the Resource. - # entry_point - The EntryPoint object to inject the cofnigutation. + # entry_point - The EntryPoint object to inject the configutation. def initialize(representation, entry_point) @links = LinkCollection.new(representation['_links'], entry_point) @embedded = ResourceCollection.new(representation['_embedded'], entry_point) @attributes = Attributes.new(representation) @entry_point = entry_point end + def inspect + "#<#{self.class.name} self_link:#{self_link.inspect} attributes:#{@attributes.inspect}>" + end + private # Internal: Returns the self Link of the Resource. Used to handle the HTTP - # connections. + # methods. def self_link @links['self'] end end end