Sha256: 66956da4be886a0b95fb50958e091c3fb050335e49b1cca0db2d1a825fa78379
Contents?: true
Size: 711 Bytes
Versions: 2
Compression:
Stored size: 711 Bytes
Contents
module JSONAPI # c.f. http://jsonapi.org/format/#document-links class Links def initialize(links_hash, options = {}) fail InvalidDocument, "the value of 'links' MUST be an object" unless links_hash.is_a?(Hash) @hash = links_hash @links = {} links_hash.each do |link_name, link_val| @links[link_name.to_s] = Link.new(link_val, options) define_singleton_method(link_name) do @links[link_name.to_s] end end end def to_hash @hash end def defined?(link_name) @links.key?(link_name.to_s) end def [](link_name) @links[link_name.to_s] end def keys @links.keys end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
jsonapi-0.1.1.beta2 | lib/jsonapi/links.rb |
jsonapi-0.1.1.beta1 | lib/jsonapi/links.rb |