Module: Brazil::ObjectExtensions
- Defined in:
- lib/brazil.rb
Constant Summary
collapse
- NEH_METHOD_REGEXP =
/\A(?<method_name>.+)_neh\?\z/
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ Object
15
16
17
18
19
20
21
|
# File 'lib/brazil.rb', line 15
def method_missing(meth, *args, &block)
if (m = NEH_METHOD_REGEXP.match(meth))
self.public_send("#{m[:method_name]}?", *args, &block)
else
super
end
end
|
Instance Method Details
#respond_to_missing?(meth, include_all = false) ⇒ Boolean
7
8
9
10
11
12
13
|
# File 'lib/brazil.rb', line 7
def respond_to_missing?(meth, include_all = false)
if (m = NEH_METHOD_REGEXP.match(meth))
super || self.respond_to?("#{m[:method_name]}?", include_all)
else
super
end
end
|