Class: Verifly::Applicator::MethodExtractor
- Inherits:
-
Verifly::Applicator
- Object
- Verifly::Applicator
- Verifly::Applicator::MethodExtractor
- Defined in:
- lib/verifly/applicator.rb
Overview
MethodExtractor is used when applicable is a symbol. It extracts a method from binding_ and executes it on binding_ (so it works just like send except it sends nothing when method arity is zero).
Instance Attribute Summary
Attributes inherited from Verifly::Applicator
Class Method Summary collapse
Instance Method Summary collapse
-
#binding_method(binding_) ⇒ Method
Method, extracted from binding.
-
#call(binding_, *context) ⇒ Object
Application result.
-
#source(binding_) ⇒ String
Relative method source defenition.
-
#source_location(binding_) ⇒ [String, Integer]
(file, line) location of calblack source (if exists).
Methods inherited from Verifly::Applicator
Methods included from ClassBuilder::Mixin
#build, #build_class, #buildable_classes=
Constructor Details
This class inherits a constructor from Verifly::Applicator
Class Method Details
.build_class(applicable) ⇒ Object
59 60 61 |
# File 'lib/verifly/applicator.rb', line 59 def self.build_class(applicable) self if applicable.is_a?(Symbol) end |
Instance Method Details
#binding_method(binding_) ⇒ Method
Returns method, extracted from binding.
90 91 92 |
# File 'lib/verifly/applicator.rb', line 90 def binding_method(binding_) binding_.is_a?(Binding) ? binding_.receiver : binding_ end |
#call(binding_, *context) ⇒ Object
Returns application result.
66 67 68 69 70 71 72 |
# File 'lib/verifly/applicator.rb', line 66 def call(binding_, *context) if binding_.is_a?(Binding) call_on_binding(binding_, *context) else invoke_lambda(binding_.method(applicable), binding_, *context) end end |
#source(binding_) ⇒ String
Returns relative method source defenition.
84 85 86 |
# File 'lib/verifly/applicator.rb', line 84 def source(binding_) binding_method(binding_).method(applicable).source end |
#source_location(binding_) ⇒ [String, Integer]
Returns (file, line) location of calblack source (if exists).
77 78 79 |
# File 'lib/verifly/applicator.rb', line 77 def source_location(binding_) binding_method(binding_).method(applicable).source_location end |