Module: Slingshot::Model::Persistence::Attributes::InstanceMethods
- Defined in:
- lib/slingshot/model/persistence/attributes.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
Instance Method Summary collapse
- #attribute_names ⇒ Object
- #attributes ⇒ Object
- #has_attribute?(name) ⇒ Boolean (also: #has_property?)
- #initialize(attributes = {}) ⇒ Object
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
34 35 36 |
# File 'lib/slingshot/model/persistence/attributes.rb', line 34 def id @id end |
Instance Method Details
#attribute_names ⇒ Object
45 46 47 |
# File 'lib/slingshot/model/persistence/attributes.rb', line 45 def attribute_names self.class.properties.sort end |
#attributes ⇒ Object
40 41 42 43 |
# File 'lib/slingshot/model/persistence/attributes.rb', line 40 def attributes self.class.properties. inject( self.id ? {'id' => self.id} : {} ) {|attributes, key| attributes[key] = send(key); attributes} end |
#has_attribute?(name) ⇒ Boolean Also known as: has_property?
49 50 51 |
# File 'lib/slingshot/model/persistence/attributes.rb', line 49 def has_attribute?(name) properties.include?(name.to_s) end |
#initialize(attributes = {}) ⇒ Object
36 37 38 |
# File 'lib/slingshot/model/persistence/attributes.rb', line 36 def initialize(attributes={}) attributes.each { |name, value| send("#{name}=", value) } end |