class Animator::Eraminho

Public Instance Methods

animable() click to toggle source
# File lib/animator/eraminho.rb, line 27
def animable
  animable! rescue nil
end
animable!() click to toggle source
# File lib/animator/eraminho.rb, line 31
def animable!
  unless @animable
    animable_class.constantize rescue nil # This is required because of ActiveSupport's lazy loading
    @animable = YAML.load(anima)

    raise(ReanimationError, "#{@animable.class.name} has not included Animator::Animable") unless @animable.is_a?(Animable)

    @animable.instance_variable_set(:@destroyed, true)
    @animable.instance_variable_set(:@eraminho, self)
  end

  @animable
end
animable=(animable) click to toggle source
# File lib/animator/eraminho.rb, line 14
def animable=(animable)
  if animable
    raise(TypeError, "Attempted to set #{animable.inspect} as the animable of an Eraminho, but #{animable.class.name} has not included Animator::Animable") unless animable.is_a?(Animable)

    self.animable_class = animable.class.name
    self.animable_id = animable[animable.class.primary_key] if animable.class.primary_key
    self.transaction_uuid = get_current_transaction_uuid(animable.class.connection)
    self.anima = YAML.dump(animable)
  end

  @animable = animable
end

Private Instance Methods

get_current_transaction_uuid(connection) click to toggle source
# File lib/animator/eraminho.rb, line 47
def get_current_transaction_uuid(connection)
  connection.current_transaction.instance_eval { @__animator_transaction_uuid__ ||= SecureRandom.uuid }
end