Sha256: 0c3bafef94f5070beb5fa9d998dc47c6936448dbd44d27267f7252b025e00c88
Contents?: true
Size: 860 Bytes
Versions: 1
Compression:
Stored size: 860 Bytes
Contents
module Yaks class Resource include Attributes.new( type: nil, links: [], attributes: {}, subresources: {}, controls: [] ), Enumerable def [](attr) attributes[attr] end def each return to_enum unless block_given? yield self end def self_link links.reverse.find do |link| link.rel.equal? :self end end def collection? false end def null_resource? false end def update_attributes(new_attrs) update(attributes: @attributes.merge(new_attrs)) end def add_link(link) append_to(:links, link) end def add_control(control) append_to(:controls, control) end def add_subresource(rel, subresource) update(subresources: @subresources.merge(rel => subresource)) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
yaks-0.6.0 | lib/yaks/resource.rb |