Class: TrickSerial::Serializer::ActiveRecordProxy

Inherits:
Object
  • Object
show all
Includes:
ObjectProxy
Defined in:
lib/trick_serial/serializer.rb

Overview

module

Instance Attribute Summary

Attributes included from ObjectProxy

#cls, #id

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ObjectProxy

included, #initialize, #object=, #resolve_class

Class Method Details

.can_proxy?(obj) ⇒ Boolean

Returns:

  • (Boolean)


321
322
323
# File 'lib/trick_serial/serializer.rb', line 321

def self.can_proxy?(obj)
  obj.id
end

Instance Method Details

#objectObject



325
326
327
328
329
330
# File 'lib/trick_serial/serializer.rb', line 325

def object
  # STDERR.puts "#{self}#object find #{@cls.inspect} #{@id.inspect}" unless @object
  @object ||= 
    resolve_class.find(@id) || 
    (raise Error::DisappearingObject, "#{@cls.inspect} #{@id.inspect}")
end