Sha256: fdee6494ee9f95794b36d036ce88f6a5502a0513d7fdf8864ea8f2b5fed4349d
Contents?: true
Size: 813 Bytes
Versions: 7
Compression:
Stored size: 813 Bytes
Contents
require 'hyperclient/collection' module Hyperclient # Public: A wrapper class to easily acces the attributes in a Resource. # # Examples # # resource.attributes['title'] # resource.attributes.title # class Attributes < Collection RESERVED_PROPERTIES = [/^_links$/, /^_embedded$/] # http://tools.ietf.org/html/draft-kelly-json-hal#section-4.1 # Public: Initializes the Attributes of a Resource. # # representation - The hash with the HAL representation of the Resource. # def initialize(representation) @collection = if representation.is_a?(Hash) representation.delete_if { |key, _value| RESERVED_PROPERTIES.any? { |p| p.match(key) } } else representation end end end end
Version data entries
7 entries across 7 versions & 1 rubygems