Sha256: 79fbcbe50f2881bb6ae5a246a062b07d0109850df063a65aa45bad98231ff50b
Contents?: true
Size: 786 Bytes
Versions: 10
Compression:
Stored size: 786 Bytes
Contents
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$/].freeze # 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
10 entries across 10 versions & 1 rubygems