module Animator::Animable
Public Instance Methods
animable?()
click to toggle source
# File lib/animator/animable.rb, line 51 def animable? destroyed? && !@eraminho.nil? end
divine(options = {}, &block)
click to toggle source
# File lib/animator/animable.rb, line 33 def divine(options = {}, &block) options = { validate: false }.merge(options) result = nil eraminho = @eraminho destroyed = @destroyed transaction do reanimate!(options) result = instance_exec(&block) raise ActiveRecord::Rollback end @eraminho = eraminho @destroyed = destroyed result end
eraminho()
click to toggle source
# File lib/animator/animable.rb, line 101 def eraminho @eraminho end
reanimate(options = {}, validation_queue = nil)
click to toggle source
# File lib/animator/animable.rb, line 97 def reanimate(options = {}, validation_queue = nil) reanimate!(options, validation_queue) rescue self end
reanimate!(options = {}, validation_queue = nil)
click to toggle source
# File lib/animator/animable.rb, line 55 def reanimate!(options = {}, validation_queue = nil) klass = self.class options = { force: false, transactional: true, validate: true }.merge(options) raise(ReanimationError, "#{inspect} is not animable.") unless animable? transaction do if validation_queue run_callbacks(:reanimate) do if options[:transactional] Eraminho.with_transaction_uuid(@eraminho.transaction_uuid).find_each do |eraminho| if options[:force] eraminho.animable!.reanimate(options.merge(transactional: false, force: false), validation_queue) else eraminho.animable!.reanimate!(options.merge(transactional: false, force: false), validation_queue) end end else klass.unscoped.insert arel_attributes_with_values_for_create attribute_names validation_queue << self if options[:validate] @eraminho.delete end end @eraminho = nil @destroyed = false else validation_queue = [] reanimate!(options, validation_queue) validation_queue.each do |animable| unless animable.valid?(:reanimate) raise(ActiveRecord::RecordInvalid.new(animable)) end end end end self end