Module: EagerBeaver
- Defined in:
- lib/eager_beaver.rb,
lib/eager_beaver/version.rb,
lib/eager_beaver/method_matcher.rb
Defined Under Namespace
Modules: ClassMethods
Classes: MethodMatcher
Constant Summary
collapse
- VERSION =
"0.0.1"
Class Method Summary
collapse
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/eager_beaver.rb', line 10
def method_missing(method_name, *args, &block)
self.class.method_matchers.each do |method_matcher|
method_matcher.original_caller = self
if method_matcher.match?(method_name)
if method_matcher.new_method
self.class.send(:define_method, method_name, method_matcher.new_method)
elsif method_matcher.new_method_code_maker
method_string = method_matcher.instance_eval &method_matcher.new_method_code_maker
self.class.class_eval method_string, __FILE__, __LINE__ + 1
end
return self.send(method_name, *args, &block)
end
end
super
end
|
Class Method Details
.included(includer) ⇒ Object
6
7
8
|
# File 'lib/eager_beaver.rb', line 6
def self.included(includer)
includer.extend(ClassMethods)
end
|
Instance Method Details
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
26
27
28
29
30
31
|
# File 'lib/eager_beaver.rb', line 26
def respond_to_missing?(method_name, include_private=false)
self.class.method_matchers.each do |method_matcher|
return true if method_matcher.match?(method_name)
end
super
end
|