Class: Saviour::PersistenceLayer

Inherits:
Object
  • Object
show all
Defined in:
lib/saviour/persistence_layer.rb

Instance Method Summary collapse

Constructor Details

#initialize(model) ⇒ PersistenceLayer

Returns a new instance of PersistenceLayer.



3
4
5
# File 'lib/saviour/persistence_layer.rb', line 3

def initialize(model)
  @model = model
end

Instance Method Details

#persisted?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/saviour/persistence_layer.rb', line 19

def persisted?
  @model.persisted? || @model.destroyed?
end

#read(attr) ⇒ Object



7
8
9
# File 'lib/saviour/persistence_layer.rb', line 7

def read(attr)
  @model.read_attribute(attr)
end

#write(attr, value) ⇒ Object



11
12
13
# File 'lib/saviour/persistence_layer.rb', line 11

def write(attr, value)
  @model.update_columns(attr => value)
end

#write_attrs(attributes) ⇒ Object



15
16
17
# File 'lib/saviour/persistence_layer.rb', line 15

def write_attrs(attributes)
  @model.update_columns(attributes)
end