Class: Ramaze::SequelCache
Overview
Defined Under Namespace
Classes: Table
Class Method Summary collapse
- .[](key) ⇒ Object
- .[]=(key, value) ⇒ Object
- .clear ⇒ Object
- .delete(*keys) ⇒ Object
- .new ⇒ Object
- .to_sym ⇒ Object
- .values_at(*keys) ⇒ Object
Instance Method Summary collapse
Class Method Details
.[](key) ⇒ Object
34 35 36 37 |
# File 'lib/ramaze/contrib/sequel_cache.rb', line 34 def self.[] key record = Table.find :key => key record ? record.value : nil end |
.[]=(key, value) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/ramaze/contrib/sequel_cache.rb', line 39 def self.[]= key, value begin Table.create :key => key, :value => value rescue Table.filter(:key => key).update :value => value unless Table.find(:key => key) Table.create :key => key, :value => value rescue nil end end # ruby always returns 'value' for []= ! rescue nil end |
.clear ⇒ Object
64 65 66 |
# File 'lib/ramaze/contrib/sequel_cache.rb', line 64 def self.clear Table.delete_all end |
.delete(*keys) ⇒ Object
57 58 59 60 61 62 |
# File 'lib/ramaze/contrib/sequel_cache.rb', line 57 def self.delete *keys keys.map do |key| record = Table[key] record.delete if record end end |
.new ⇒ Object
68 69 70 |
# File 'lib/ramaze/contrib/sequel_cache.rb', line 68 def self.new self end |
.to_sym ⇒ Object
72 73 74 |
# File 'lib/ramaze/contrib/sequel_cache.rb', line 72 def self.to_sym name.split(%r/::/).last.to_sym end |