Class: Wlog::KeyValue
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Wlog::KeyValue
- Defined in:
- lib/wlog/domain/key_value.rb
Overview
Class Method Summary collapse
-
.get(key) ⇒ Object
Get a certain value by key.
-
.put!(key, value) ⇒ Object
Insert a key in the storage.
Class Method Details
.get(key) ⇒ Object
Get a certain value by key
26 27 28 29 |
# File 'lib/wlog/domain/key_value.rb', line 26 def self.get(key) ret = find_by_key(key) ret = ret ? ret.value : nil end |
.put!(key, value) ⇒ Object
Insert a key in the storage. If exists, replace the value with new one
15 16 17 18 19 20 21 22 |
# File 'lib/wlog/domain/key_value.rb', line 15 def self.put!(key, value) if ret = KeyValue.find_by_key(key) ret.value = value else ret = KeyValue.new(:key => key, :value => value) end ret.save nil end |