Module: ZendeskAPI::Associations
- Included in:
- Data
- Defined in:
- lib/zendesk_api/association.rb
Overview
This module holds association method for resources. Associations can be loaded in three ways:
-
Commonly used resources are automatically side-loaded server side and sent along with their parent object.
-
Associated resource ids are sent and are then loaded one-by-one into the parent collection.
-
The association is represented with Rails’ nested association urls (such as tickets/:id/groups) and are loaded that way.
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
Instance Method Details
#wrap_resource(resource, klass, class_level_association) ⇒ Object
96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/zendesk_api/association.rb', line 96 def wrap_resource(resource, klass, class_level_association) instance_association = Association.new(class_level_association.merge(:parent => self)) case resource when Hash klass.new(@client, resource.merge(:association => instance_association)) when String, Fixnum klass.new(@client, :id => resource, :association => instance_association) else resource.association = instance_association resource end end |