Class: Lolita::Register
Instance Method Summary collapse
- #filter(*args) ⇒ Object
- #get(key) ⇒ Object
- #get_with_options(key) ⇒ Object
-
#initialize ⇒ Register
constructor
A new instance of Register.
- #set(key, value, options = nil) ⇒ Object
Constructor Details
#initialize ⇒ Register
Returns a new instance of Register.
4 5 6 |
# File 'lib/lolita/register.rb', line 4 def initialize @store = {} end |
Instance Method Details
#filter(*args) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/lolita/register.rb', line 20 def filter *args = args. values = if args.first [(args.first)] else @store.values end filter_values(values,) end |
#get(key) ⇒ Object
12 13 14 |
# File 'lib/lolita/register.rb', line 12 def get key item = @store[key] and item.first end |
#get_with_options(key) ⇒ Object
16 17 18 |
# File 'lib/lolita/register.rb', line 16 def key @store[key] end |
#set(key, value, options = nil) ⇒ Object
8 9 10 |
# File 'lib/lolita/register.rb', line 8 def set key, value, =nil !!(@store[key] = [value,].compact) end |