Method: DataMapper::Hook::ClassMethods#inline_call
- Defined in:
- lib/dm-core/support/hook.rb
#inline_call(method_info, scope) ⇒ Object
Returns ruby code that will invoke the hook. It checks the arity of the hook method and passes arguments accordingly.
263 264 265 266 267 268 269 270 271 272 273 |
# File 'lib/dm-core/support/hook.rb', line 263 def inline_call(method_info, scope) DataMapper::Hook::ClassMethods.hook_scopes << method_info[:from] name = method_info[:name] if scope == :instance args = method_defined?(name) && instance_method(name).arity != 0 ? '*args' : '' %(#{name}(#{args}) if self.class <= DataMapper::Hook::ClassMethods.object_by_id(#{method_info[:from].object_id})) else args = respond_to?(name) && method(name).arity != 0 ? '*args' : '' %(#{name}(#{args}) if self <= DataMapper::Hook::ClassMethods.object_by_id(#{method_info[:from].object_id})) end end |