164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
|
# File 'lib/github_api/api.rb', line 164
def self.method_added(method_name)
method_name = method_name.to_s.gsub(/_with(out)?_callback_.*$/, '')
return if self.root?
return if .include?(method_name)
return unless request_methods.include?(method_name)
return if (@__methods_added ||= []).include?(method_name)
class_name = self.name.to_s.split('::').last.downcase
with_method = "#{method_name}_with_callback_#{class_name}"
without_method = "#{method_name}_without_callback_#{class_name}"
return if public_method_defined?(with_method)
[method_name, with_method, without_method].each do |met|
@__methods_added << met
end
return if public_method_defined?(with_method)
define_method(with_method) do |*args, &block|
send(:execute, without_method, *args, &block)
end
alias_method without_method, method_name
alias_method method_name, with_method
clear_request_methods!
end
|