Class: Redis::Breadcrumb
- Inherits:
-
Object
- Object
- Redis::Breadcrumb
- Defined in:
- lib/redis-breadcrumbs/breadcrumb.rb
Instance Attribute Summary collapse
-
#tracked_in ⇒ Object
readonly
Returns the value of attribute tracked_in.
Class Method Summary collapse
Instance Method Summary collapse
- #clean! ⇒ Object
-
#initialize(object = Breadcrumbs::UnspecializedDummyObject.new) ⇒ Breadcrumb
constructor
A new instance of Breadcrumb.
- #reset! ⇒ Object
- #track! ⇒ Object
- #tracked_keys ⇒ Object
Methods included from Breadcrumbs::Entrance
Methods included from Breadcrumbs::AsMethods
Methods included from Breadcrumbs::Dsl
Constructor Details
#initialize(object = Breadcrumbs::UnspecializedDummyObject.new) ⇒ Breadcrumb
Returns a new instance of Breadcrumb.
21 22 23 24 |
# File 'lib/redis-breadcrumbs/breadcrumb.rb', line 21 def initialize object=Breadcrumbs::UnspecializedDummyObject.new @tracked_in = self.class.tracked_in_key.specialize(object).to_s @keys = self.class.keys.specialize object end |
Instance Attribute Details
#tracked_in ⇒ Object (readonly)
Returns the value of attribute tracked_in.
19 20 21 |
# File 'lib/redis-breadcrumbs/breadcrumb.rb', line 19 def tracked_in @tracked_in end |
Class Method Details
.method_missing(mthd, *args) ⇒ Object
14 15 16 |
# File 'lib/redis-breadcrumbs/breadcrumb.rb', line 14 def method_missing mthd, *args new.send(mthd) end |
Instance Method Details
#clean! ⇒ Object
38 39 40 |
# File 'lib/redis-breadcrumbs/breadcrumb.rb', line 38 def clean! run_cmds Set.new(tracked_keys.concat(@keys.clean_cmds)) end |
#reset! ⇒ Object
34 35 36 |
# File 'lib/redis-breadcrumbs/breadcrumb.rb', line 34 def reset! run_cmds @keys.reset_cmds end |
#track! ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/redis-breadcrumbs/breadcrumb.rb', line 26 def track! return if @tracked_in.nil? || @tracked_in == "" jsons = @keys.clean_cmds.map(&:to_json) redis.sadd @tracked_in, jsons end |
#tracked_keys ⇒ Object
42 43 44 45 46 |
# File 'lib/redis-breadcrumbs/breadcrumb.rb', line 42 def tracked_keys redis.smembers(@tracked_in).map do |json| JSON.parse(json) end end |