Class: Breadcrumbs::OwnedKey

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

Instance Method Summary collapse

Methods inherited from Key

#to_s

Constructor Details

#initialize(key_template, options) ⇒ OwnedKey

Returns a new instance of OwnedKey.



3
4
5
6
7
# File 'lib/redis-breadcrumbs/owned_key.rb', line 3

def initialize key_template, options
  @options = options || {}
  @key_template = key_template
  @resetable = options[:reset]
end

Instance Method Details

#clean_cmdObject



13
14
15
# File 'lib/redis-breadcrumbs/owned_key.rb', line 13

def clean_cmd
  [:del, @key_template]
end

#key_nameObject



21
22
23
# File 'lib/redis-breadcrumbs/owned_key.rb', line 21

def key_name
  @key_template
end

#reset_cmdObject



17
18
19
# File 'lib/redis-breadcrumbs/owned_key.rb', line 17

def reset_cmd
  clean_cmd if @resetable
end

#specialize(object) ⇒ Object



9
10
11
# File 'lib/redis-breadcrumbs/owned_key.rb', line 9

def specialize object
  OwnedKey.new specialize_from_template(@key_template, object), @options
end