Sha256: 7608cc5e92d0f87b2656aa91a81dd7aeecb204551920ffdf7ada08472c7b9261
Contents?: true
Size: 839 Bytes
Versions: 4
Compression:
Stored size: 839 Bytes
Contents
require 'object_attorney/errors' module ObjectAttorney module Helpers module_function def marked_for_destruction?(object) return false unless object.respond_to?(:marked_for_destruction?) object.marked_for_destruction? end def call_proc_or_method(base, proc_or_method, object = nil) if proc_or_method.is_a?(Proc) base.instance_exec(object, &proc_or_method) else call_method!(base, proc_or_method, object) end end def call_method!(base, method, *args) unless base.respond_to?(method) raise NotImplementedError, "#{base} does not respond to #{method}" end base.send(method, *args) end def extend_errors_if_necessary(object) return if object.respond_to?(:errors) object.class.send(:include, Errors) end end end
Version data entries
4 entries across 4 versions & 1 rubygems