module ZendeskAPI::Associations
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.
@private
Public Class Methods
included(base)
click to toggle source
# File lib/zendesk_api/associations.rb, line 12 def self.included(base) base.extend ClassMethods end
Public Instance Methods
wrap_resource(resource, class_level_association, options = {})
click to toggle source
# File lib/zendesk_api/associations.rb, line 16 def wrap_resource(resource, class_level_association, options = {}) instance_association = Association.new(class_level_association.merge(:parent => self)) klass = class_level_association[:class] case resource when Hash klass.new(@client, resource.merge(:association => instance_association)) when String, Integer klass.new(@client, (options[:include_key] || :id) => resource, :association => instance_association) else resource.association = instance_association resource end end