Module: Fleakr::Support::Object::InstanceMethods
- Defined in:
- lib/fleakr/support/object.rb
Instance Attribute Summary collapse
-
#authentication_options ⇒ Object
readonly
Returns the value of attribute authentication_options.
-
#document ⇒ Object
readonly
Returns the value of attribute document.
Instance Method Summary collapse
- #associations ⇒ Object
- #initialize(document = nil, options = {}) ⇒ Object
- #inspect ⇒ Object
- #populate_from(document) ⇒ Object
Instance Attribute Details
#authentication_options ⇒ Object (readonly)
Returns the value of attribute authentication_options.
98 99 100 |
# File 'lib/fleakr/support/object.rb', line 98 def @authentication_options end |
#document ⇒ Object (readonly)
Returns the value of attribute document.
98 99 100 |
# File 'lib/fleakr/support/object.rb', line 98 def document @document end |
Instance Method Details
#associations ⇒ Object
120 121 122 |
# File 'lib/fleakr/support/object.rb', line 120 def associations @associations ||= {} end |
#initialize(document = nil, options = {}) ⇒ Object
100 101 102 103 |
# File 'lib/fleakr/support/object.rb', line 100 def initialize(document = nil, = {}) self.populate_from(document) unless document.nil? @authentication_options = .extract!(:auth_token) end |
#inspect ⇒ Object
113 114 115 116 117 118 |
# File 'lib/fleakr/support/object.rb', line 113 def inspect names = instance_variables.reject {|n| %w(@associations @document).include?(n.to_s) } attributes = names.map {|n| "#{n}=#{instance_variable_get(n).inspect}" } "#<#{self.class} #{attributes.join(', ')}>" end |
#populate_from(document) ⇒ Object
105 106 107 108 109 110 111 |
# File 'lib/fleakr/support/object.rb', line 105 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 |