Module: Breadcrumbs::Dsl::ClassMethods
- Defined in:
- lib/redis-breadcrumbs/dsl.rb
Instance Method Summary collapse
- #keys ⇒ Object
- #member_of_set(options) ⇒ Object
- #member_of_sets ⇒ Object
- #member_of_sorted_set(options) ⇒ Object (also: #member_of_zset)
- #member_of_sorted_sets ⇒ Object
- #owned_keys ⇒ Object
- #owns(key_template, options = {}) ⇒ Object
- #redis ⇒ Object
- #redis=(redis) ⇒ Object
- #tracked_in(*args) ⇒ Object
- #tracked_in_key ⇒ Object
- #tracked_keys ⇒ Object
Instance Method Details
#keys ⇒ Object
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 add_member_of_set , member_of_sets, :srem end |
#member_of_sets ⇒ Object
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 add_member_of_set , member_of_sorted_sets, :zrem end |
#member_of_sorted_sets ⇒ Object
68 69 70 |
# File 'lib/redis-breadcrumbs/dsl.rb', line 68 def member_of_sorted_sets @member_of_sorted_sets ||= [] end |
#owned_keys ⇒ Object
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, ={} owned_keys << key_template as = .delete(:as) key = OwnedKey.new key_template, keys[key_template] = OwnedKey.new(key_template, ) create_as_method key_template, as unless as.nil? end |
#redis ⇒ Object
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_key ⇒ Object
27 28 29 |
# File 'lib/redis-breadcrumbs/dsl.rb', line 27 def tracked_in_key Key.new tracked_in end |
#tracked_keys ⇒ Object
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 |