Module: Subjoin::Attributable

Included in:
Meta, Resource
Defined in:
lib/subjoin/attributable.rb

Overview

Generically handle arbitrary object attributes

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#attributesHash (readonly)

The object’s attributes

Returns:

  • (Hash)


8
9
10
# File 'lib/subjoin/attributable.rb', line 8

def attributes
  @attributes
end

Instance Method Details

#[](name) ⇒ Object

Access an attribute by property name

Parameters:

  • name (String)

    the property name

Returns:

  • The property value, or nil if no such property exists



20
21
22
23
24
25
26
# 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) ⇒ Object

Load the object’s attributes

Parameters:

  • data (Hash)

    The object’s parsed JSON attribute member



12
13
14
# File 'lib/subjoin/attributable.rb', line 12

def load_attributes(data)
  @attributes = data
end