Module: Virsandra::Model::InstanceMethods
- Defined in:
- lib/virsandra/model.rb
Instance Method Summary collapse
Instance Method Details
#==(other) ⇒ Object
36 37 38 |
# File 'lib/virsandra/model.rb', line 36 def ==(other) other.is_a?(self.class) && attributes == other.attributes end |
#delete ⇒ Object
32 33 34 |
# File 'lib/virsandra/model.rb', line 32 def delete ModelQuery.new(self).delete end |
#key ⇒ Object
13 14 15 16 17 18 |
# File 'lib/virsandra/model.rb', line 13 def key self.class.key.reduce({}) do |key, col| key[col] = attributes[col] key end end |
#save ⇒ Object
28 29 30 |
# File 'lib/virsandra/model.rb', line 28 def save ModelQuery.new(self).save if valid? end |
#table ⇒ Object
20 21 22 |
# File 'lib/virsandra/model.rb', line 20 def table self.class.table end |
#valid? ⇒ Boolean
24 25 26 |
# File 'lib/virsandra/model.rb', line 24 def valid? self.class.valid_key?(key) end |