Module: ObjectAttorney::Representation

Defined in:
lib/object_attorney/representation.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#read_attribute_for_serialization(attribute) ⇒ Object



5
6
7
# File 'lib/object_attorney/representation.rb', line 5

def read_attribute_for_serialization(attribute)
  respond_to?(attribute) ? send(attribute) : nil
end

#represented_objectObject



15
16
17
# File 'lib/object_attorney/representation.rb', line 15

def represented_object
  @represented_object ||= self.class.represented_object_class.try(:new)
end

#send_to_representative(method_name, *args) ⇒ Object



9
10
11
12
13
# File 'lib/object_attorney/representation.rb', line 9

def send_to_representative(method_name, *args)
  return false if represented_object.blank?

  represented_object.send(method_name, *args)
end