Sha256: 93cbbca969f2b55347276af596fc9c53ab81d02fcff2619d58568110a38e75aa
Contents?: true
Size: 596 Bytes
Versions: 9
Compression:
Stored size: 596 Bytes
Contents
module ResourceKit class MethodFactory def self.construct(object, resource_collection, invoker = ActionInvoker) resource_collection.each do |action| if object.method_defined?(action.name) raise ArgumentError, "Action '#{action.name}' is already defined on `#{object}`" end method_block = method_for_action(action, invoker) object.send(:define_method, action.name, &method_block) end end def self.method_for_action(action, invoker) Proc.new do |*args| invoker.call(action, self, *args) end end end end
Version data entries
9 entries across 9 versions & 1 rubygems