Module: Slingshot::Model::Persistence::Attributes::InstanceMethods

Defined in:
lib/slingshot/model/persistence/attributes.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#idObject

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_namesObject



45
46
47
# File 'lib/slingshot/model/persistence/attributes.rb', line 45

def attribute_names
  self.class.properties.sort
end

#attributesObject



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?

Returns:

  • (Boolean)


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