Class: OldApiResource::Associations::MultiObjectProxy

Inherits:
AssociationProxy show all
Includes:
Enumerable
Defined in:
lib/old_api_resource/associations/multi_object_proxy.rb

Instance Attribute Summary

Attributes inherited from AssociationProxy

#klass, #loaded, #remote_path, #scopes, #times_loaded

Instance Method Summary collapse

Methods inherited from AssociationProxy

#initialize, #inspect, #method_missing, #reload, #scope?, #to_s

Constructor Details

This class inherits a constructor from OldApiResource::Associations::AssociationProxy

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class OldApiResource::Associations::AssociationProxy

Instance Method Details

#allObject



11
12
13
# File 'lib/old_api_resource/associations/multi_object_proxy.rb', line 11

def all
  self.internal_object
end

#each(*args, &block) ⇒ Object



15
16
17
# File 'lib/old_api_resource/associations/multi_object_proxy.rb', line 15

def each(*args, &block)
  self.internal_object.each(*args, &block)
end

#internal_objectObject

force a load when calling this method



24
25
26
# File 'lib/old_api_resource/associations/multi_object_proxy.rb', line 24

def internal_object
  @internal_object ||= self.load_scope_with_options(:all, {})
end

#internal_object=(contents) ⇒ Object



28
29
30
31
# File 'lib/old_api_resource/associations/multi_object_proxy.rb', line 28

def internal_object=(contents)
  return @internal_object = contents if contents.all?{|o| o.is_a?(self.klass)}
  return load(contents)
end

#serializable_hash(options) ⇒ Object



19
20
21
# File 'lib/old_api_resource/associations/multi_object_proxy.rb', line 19

def serializable_hash(options)
  self.internal_object.collect{|obj| obj.serializable_hash(options) }
end