Module: Fleakr::Support::Object::InstanceMethods

Defined in:
lib/fleakr/support/object.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#authentication_optionsObject (readonly)

Returns the value of attribute authentication_options.



94
95
96
# File 'lib/fleakr/support/object.rb', line 94

def authentication_options
  @authentication_options
end

#documentObject (readonly)

Returns the value of attribute document.



94
95
96
# File 'lib/fleakr/support/object.rb', line 94

def document
  @document
end

Instance Method Details

#initialize(document = nil, options = {}) ⇒ Object



96
97
98
99
# File 'lib/fleakr/support/object.rb', line 96

def initialize(document = nil, options = {})
  self.populate_from(document) unless document.nil?
  @authentication_options = options.extract!(:auth_token)
end

#populate_from(document) ⇒ Object



101
102
103
104
105
106
107
# File 'lib/fleakr/support/object.rb', line 101

def populate_from(document)
  @document = document
  self.class.attributes.each do |attribute|
    value = attribute.value_from(document)
    self.send("#{attribute.name}=".to_sym, value) unless value.nil?
  end
end