Module: ActsAsAsync::Helper::SharedMethods
- Defined in:
- lib/acts_as_async/helper.rb
Constant Summary
collapse
- METHOD_REGEXP =
/\Aasync_([a-zA-Z]\w*?)(_at|_in)?(!)?\z/
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_id, *args, &block) ⇒ Object
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
# File 'lib/acts_as_async/helper.rb', line 65
def method_missing(method_id, *args, &block)
if method_id.to_s =~ METHOD_REGEXP
method = "#{$1}#{$3}"
if respond_to? method, true
if $2.nil?
__send__(:async, method, *args)
else
__send__("async#{$2}", args.shift, method, *args)
end
else
message = "Tried to async the method #{method} but it isn't defined."
raise NoMethodError, message
end
else
super
end
end
|
Instance Method Details
#respond_to?(method_id) ⇒ Boolean
98
99
100
|
# File 'lib/acts_as_async/helper.rb', line 98
def respond_to?(method_id, *)
!!(method_id.to_s =~ METHOD_REGEXP) || super
end
|
#respond_to_missing?(method_id) ⇒ Boolean
94
95
96
|
# File 'lib/acts_as_async/helper.rb', line 94
def respond_to_missing?(method_id, *)
!!(method_id =~ METHOD_REGEXP) || super
end
|