module Subjoin::Attributable

Generically handle arbitrary object attributes @see jsonapi.org/format/#document-resource-object-attributes

Attributes

attributes[R]

The object's attributes @return [Hash]

Public Instance Methods

[](name) click to toggle source

Access an attribute by property name @param name [String] the property name @return The property value, or nil if no such property exists

# File lib/subjoin/attributable.rb, line 20
def [](name)
  name = name.to_s
  if @attributes.has_key?(name)
    return @attributes[name]
  end
  return nil
end
load_attributes(data) click to toggle source

Load the object's attributes @param data [Hash] The object's parsed JSON `attribute` member

# File lib/subjoin/attributable.rb, line 12
def load_attributes(data)
  @attributes = data
end