Sha256: 5272774f32894cfa6f49700725574188b83e1554832b688f0ffdf6bfc3741172
Contents?: true
Size: 829 Bytes
Versions: 6
Compression:
Stored size: 829 Bytes
Contents
module Delayed class PerformableMethod def initialize(object, method_name, args) raise NoMethodError, "undefined method `#{method_name}' for #{object.inspect}" unless object.respond_to?(method_name, true) self.object = ShallowMongoid.dump(object) self.args = args.map{|a| ShallowMongoid.dump(a) } self.method_name = method_name.to_sym end def perform ShallowMongoid.load(object).send(method_name, *args.map{|a| ShallowMongoid.load(a) }) rescue Mongoid::Errors::DocumentNotFound true # do nothing if document has been removed end def display_name if object.is_a?(ShallowMongoid::DocumentStub) return "#{object.klass}[#{object.id}]##{method_name}" else "#{object.class}##{method_name}" end end end end
Version data entries
6 entries across 6 versions & 1 rubygems