Class: Lolita::Register

Inherits:
Object show all
Defined in:
lib/lolita/register.rb

Instance Method Summary collapse

Constructor Details

#initializeRegister

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
  options = args.extract_options!
  values = if args.first
    [get_with_options(args.first)]
  else
    @store.values
  end
  filter_values(values,options)
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 get_with_options key
  @store[key]
end

#set(key, value, options = nil) ⇒ Object



8
9
10
# File 'lib/lolita/register.rb', line 8

def set key, value, options=nil
  !!(@store[key] = [value,options].compact)
end