Class: Hashblue::Model

Inherits:
Object
  • Object
show all
Defined in:
lib/hashblue/model.rb

Direct Known Subclasses

Account, Contact, Message

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Model

Returns a new instance of Model.



5
6
7
8
# File 'lib/hashblue/model.rb', line 5

def initialize(attributes)
  @client = client
  @attributes = attributes
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



3
4
5
# File 'lib/hashblue/model.rb', line 3

def client
  @client
end

Class Method Details

.attribute_methods(*names) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/hashblue/model.rb', line 23

def attribute_methods(*names)
  names.each do |name|
    define_method(name) do
      @attributes[name.to_s]
    end
  end
end

.build(client, attributes = {}) ⇒ Object



19
20
21
# File 'lib/hashblue/model.rb', line 19

def build(client, attributes = {})
  new(attributes).tap {|m| m.client = client}
end

Instance Method Details

#attributesObject



10
11
12
# File 'lib/hashblue/model.rb', line 10

def attributes
  @attributes.dup
end

#eql?(m) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/hashblue/model.rb', line 14

def eql?(m)
  m.is_a?(self.class) && m.attributes.eql?(attributes)
end