Class: Glimmer::Util::ProcTracker
- Inherits:
-
Proc
- Object
- Proc
- Glimmer::Util::ProcTracker
- Defined in:
- lib/glimmer/util/proc_tracker.rb
Overview
Decorator that provides tracking facilities for Ruby procs, tracking owner (string), invoked_form method name (symbol/string), and called? (boolean)
Instance Attribute Summary collapse
-
#invoked_from ⇒ Object
readonly
Returns the value of attribute invoked_from.
-
#owner ⇒ Object
readonly
Returns the value of attribute owner.
Instance Method Summary collapse
- #call(*args) ⇒ Object
- #called? ⇒ Boolean
-
#initialize(proc = nil, owner: nil, invoked_from: nil, &block) ⇒ ProcTracker
constructor
A new instance of ProcTracker.
- #respond_to?(method_name, include_private = false) ⇒ Boolean
Constructor Details
#initialize(proc = nil, owner: nil, invoked_from: nil, &block) ⇒ ProcTracker
Returns a new instance of ProcTracker.
30 31 32 33 34 |
# File 'lib/glimmer/util/proc_tracker.rb', line 30 def initialize(proc = nil, owner: nil, invoked_from: nil, &block) super(proc || block) @owner = owner @invoked_from = invoked_from end |
Instance Attribute Details
#invoked_from ⇒ Object (readonly)
Returns the value of attribute invoked_from.
28 29 30 |
# File 'lib/glimmer/util/proc_tracker.rb', line 28 def invoked_from @invoked_from end |
#owner ⇒ Object (readonly)
Returns the value of attribute owner.
28 29 30 |
# File 'lib/glimmer/util/proc_tracker.rb', line 28 def owner @owner end |
Instance Method Details
#call(*args) ⇒ Object
36 37 38 39 |
# File 'lib/glimmer/util/proc_tracker.rb', line 36 def call(*args) __getobj__.call(*args) @called = true end |
#called? ⇒ Boolean
41 42 43 |
# File 'lib/glimmer/util/proc_tracker.rb', line 41 def called? !!@called end |
#respond_to?(method_name, include_private = false) ⇒ Boolean
45 46 47 |
# File 'lib/glimmer/util/proc_tracker.rb', line 45 def respond_to?(method_name, include_private = false) %w[owner invoked_from called?].include?(method_name.to_s) || super(method_name, include_private) end |