Class: EagerBeaver::MethodMatcher
- Inherits:
-
Object
- Object
- EagerBeaver::MethodMatcher
- Defined in:
- lib/eager_beaver/method_matcher.rb
Instance Attribute Summary collapse
-
#matcher ⇒ Object
Returns the value of attribute matcher.
-
#missing_method_name ⇒ Object
Returns the value of attribute missing_method_name.
-
#new_method ⇒ Object
Returns the value of attribute new_method.
-
#new_method_code_maker ⇒ Object
Returns the value of attribute new_method_code_maker.
-
#original_caller ⇒ Object
Returns the value of attribute original_caller.
Instance Method Summary collapse
-
#initialize(block) ⇒ MethodMatcher
constructor
A new instance of MethodMatcher.
- #match?(method_name) ⇒ Boolean
Constructor Details
#initialize(block) ⇒ MethodMatcher
Returns a new instance of MethodMatcher.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/eager_beaver/method_matcher.rb', line 11 def initialize(block) block.call(self) raise ArgumentError, "matcher Proc must be given" \ if matcher.nil? raise ArgumentError, "exactly one of new_method or new_method_code_maker Proc must be given" \ if (new_method && new_method_code_maker) || (new_method.nil? && new_method_code_maker.nil?) self end |
Instance Attribute Details
#matcher ⇒ Object
Returns the value of attribute matcher.
6 7 8 |
# File 'lib/eager_beaver/method_matcher.rb', line 6 def matcher @matcher end |
#missing_method_name ⇒ Object
Returns the value of attribute missing_method_name.
9 10 11 |
# File 'lib/eager_beaver/method_matcher.rb', line 9 def missing_method_name @missing_method_name end |
#new_method ⇒ Object
Returns the value of attribute new_method.
7 8 9 |
# File 'lib/eager_beaver/method_matcher.rb', line 7 def new_method @new_method end |
#new_method_code_maker ⇒ Object
Returns the value of attribute new_method_code_maker.
8 9 10 |
# File 'lib/eager_beaver/method_matcher.rb', line 8 def new_method_code_maker @new_method_code_maker end |
#original_caller ⇒ Object
Returns the value of attribute original_caller.
5 6 7 |
# File 'lib/eager_beaver/method_matcher.rb', line 5 def original_caller @original_caller end |
Instance Method Details
#match?(method_name) ⇒ Boolean
22 23 24 25 |
# File 'lib/eager_beaver/method_matcher.rb', line 22 def match?(method_name) self.missing_method_name = method_name.to_s self.instance_eval &matcher end |