Module: Breadcrumbs::Dsl::ClassMethods

Defined in:
lib/redis-breadcrumbs/dsl.rb

Instance Method Summary collapse

Instance Method Details

#keysObject



56
57
58
# File 'lib/redis-breadcrumbs/dsl.rb', line 56

def keys
  @keys ||= Keys.new
end

#member_of_set(options) ⇒ Object



40
41
42
# File 'lib/redis-breadcrumbs/dsl.rb', line 40

def member_of_set options
  add_member_of_set options, member_of_sets, :srem
end

#member_of_setsObject



64
65
66
# File 'lib/redis-breadcrumbs/dsl.rb', line 64

def member_of_sets
  @member_of_sets ||= []
end

#member_of_sorted_set(options) ⇒ Object Also known as: member_of_zset



44
45
46
# File 'lib/redis-breadcrumbs/dsl.rb', line 44

def member_of_sorted_set options
  add_member_of_set options, member_of_sorted_sets, :zrem
end

#member_of_sorted_setsObject



68
69
70
# File 'lib/redis-breadcrumbs/dsl.rb', line 68

def member_of_sorted_sets
  @member_of_sorted_sets ||= []
end

#owned_keysObject



60
61
62
# File 'lib/redis-breadcrumbs/dsl.rb', line 60

def owned_keys
  @owned_keys ||= []
end

#owns(key_template, options = {}) ⇒ Object



31
32
33
34
35
36
37
38
# File 'lib/redis-breadcrumbs/dsl.rb', line 31

def owns key_template, options={}
  owned_keys << key_template
  as = options.delete(:as)
  key = OwnedKey.new key_template, options
  keys[key_template] = OwnedKey.new(key_template, options)

  create_as_method key_template, as unless as.nil?
end

#redisObject



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

def redis
  @@redis
end

#redis=(redis) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/redis-breadcrumbs/dsl.rb', line 15

def redis= redis
  if defined?(Redis::Namespace) && redis.is_a?(Redis::Namespace)
    redis = redis.redis # yo dawg
  end

  @@redis = redis
end

#tracked_in(*args) ⇒ Object



23
24
25
# File 'lib/redis-breadcrumbs/dsl.rb', line 23

def tracked_in *args
  args.length > 0 ? @tracked_in = args[0] : @tracked_in
end

#tracked_in_keyObject



27
28
29
# File 'lib/redis-breadcrumbs/dsl.rb', line 27

def tracked_in_key
  Key.new tracked_in
end

#tracked_keysObject



50
51
52
53
54
# File 'lib/redis-breadcrumbs/dsl.rb', line 50

def tracked_keys
  redis.smembers(@tracked_in).map do |json|
    JSON.parse(json)
  end
end