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

#deleteObject



32
33
34
# File 'lib/virsandra/model.rb', line 32

def delete
  ModelQuery.new(self).delete
end

#keyObject



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

#saveObject



28
29
30
# File 'lib/virsandra/model.rb', line 28

def save
  ModelQuery.new(self).save if valid?
end

#tableObject



20
21
22
# File 'lib/virsandra/model.rb', line 20

def table
  self.class.table
end

#valid?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/virsandra/model.rb', line 24

def valid?
  self.class.valid_key?(key)
end