Class: Breadcrumbs::Keys

Inherits:
Object
  • Object
show all
Defined in:
lib/redis-breadcrumbs/keys.rb

Instance Method Summary collapse

Constructor Details

#initialize(keys = {}) ⇒ Keys

Returns a new instance of Keys.



7
8
9
# File 'lib/redis-breadcrumbs/keys.rb', line 7

def initialize keys={}
  @keys = keys
end

Instance Method Details

#[](key_template) ⇒ Object



11
12
13
# File 'lib/redis-breadcrumbs/keys.rb', line 11

def [] key_template
  @keys[key_template]
end

#[]=(key_template, key) ⇒ Object



15
16
17
# File 'lib/redis-breadcrumbs/keys.rb', line 15

def []= key_template, key
  @keys[key_template] = key
end

#clean_cmdsObject



25
26
27
# File 'lib/redis-breadcrumbs/keys.rb', line 25

def clean_cmds
  @keys.values.map &:clean_cmd
end

#reset_cmdsObject



29
30
31
# File 'lib/redis-breadcrumbs/keys.rb', line 29

def reset_cmds
  @keys.values.map(&:reset_cmd).compact
end

#specialize(object) ⇒ Object



19
20
21
22
23
# File 'lib/redis-breadcrumbs/keys.rb', line 19

def specialize object
  Keys.new(Hash[@keys.map do |(key_template, key)|
    [key_template, key.specialize(object)]
  end])
end