lib/zendesk_api/association.rb in zendesk_api-1.0.2 vs lib/zendesk_api/association.rb in zendesk_api-1.0.3
- old
+ new
@@ -1,18 +1,18 @@
require 'zendesk_api/helpers'
module ZendeskAPI
- # Represents an association between two resources
+ # Represents an association between two resources
# @private
class Association
# @return [Hash] Options passed into the association
attr_reader :options
# Options to pass in
# * class - Required
# * parent - Parent instance
- # * path - Optional path instead of resource name
+ # * path - Optional path instead of resource name
def initialize(options = {})
@options = Hashie::Mash.new(options)
end
# Generate a path to the resource.
@@ -30,10 +30,10 @@
end
instance = args.first
namespace = @options[:class].to_s.split("::")
- namespace.delete("ZendeskAPI")
+ %w(ZendeskAPI Voice).each { |ns| namespace.delete(ns) }
has_parent = namespace.size > 1 || (options[:with_parent] && @options.parent)
if has_parent
parent_class = @options.parent ? @options.parent.class : ZendeskAPI.const_get(ZendeskAPI::Helpers.modulize_string(namespace[0]))
parent_namespace = build_parent_namespace(parent_class, instance, options, original_options)