Class: ExtraLoop::Storage::Record

Inherits:
Ohm::Model
  • Object
show all
Includes:
Ohm::Boundaries, Ohm::Callbacks, Ohm::Timestamping, Ohm::Typecast
Defined in:
lib/extraloop/redis-storage/record.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Record

Returns a new instance of Record.



11
12
13
14
# File 'lib/extraloop/redis-storage/record.rb', line 11

def initialize attrs={}
  self.class.send(:_inherit!)
  super attrs
end

Class Method Details

.create(attrs = {}) ⇒ Object



16
17
18
19
# File 'lib/extraloop/redis-storage/record.rb', line 16

def self.create attrs={}
  _inherit!
  super attrs
end

Instance Method Details

#to_hashObject



21
22
23
24
25
# File 'lib/extraloop/redis-storage/record.rb', line 21

def to_hash
  super.merge(attributes.reduce({}) { |memo, attribute| 
    memo.merge(attribute => send(attribute)) 
  })
end

#to_yamlObject



27
28
29
# File 'lib/extraloop/redis-storage/record.rb', line 27

def to_yaml
  to_hash.to_yaml
end

#validateObject



31
32
33
# File 'lib/extraloop/redis-storage/record.rb', line 31

def validate
  assert_present :session
end