lib/zendesk_api/association.rb
# Generate a path to the resource.
# id and <parent>_id attributes will be deleted from passed in options hash if they are used in the built path.
# Arguments that can be passed in:
# An instance, any resource instance
# Hash Options:
# * with_parent - Include the parent path (false by default)
# * with_id - Include the instance id, if possible (true)
Generate a path to the resource.
id and _id attributes will be deleted from passed in options hash if they are used in the built path.
Arguments that can be passed in:
An instance, any resource instance
Hash Options:
with_parent - Include the parent path (false by default)
with_id - Include the instance id, if possible (true)
Generate a path to the resource . id and _id attributes will be deleted from passed in options hash if they are used in the built path . Arguments that can be passed in : An instance any resource instance Hash Options : with_parent - Include the parent path ( false by default ) with_id - Include the instance id if possible ( true )
def generate_path(*args)
      options = Hashie::Mash.new(:with_id => true)
      if args.last.is_a?(Hash)
        original_options = args.pop
        options.merge!(original_options)
      end
      instance = args.first
      namespace = @options[:class].to_s.split("::")
      namespace.delete("ZendeskAPI")
      has_parent = namespace.size > 1 || (options[:with_parent] && @options.parent)
      if has_parent
        parent_class = @options.parent ? @options.parent.class : ZendeskAPI.get_class(namespace[0])
        parent_namespace = build_parent_namespace(parent_class, instance, options, original_options)
        namespace[1..1] = parent_namespace if parent_namespace
        namespace[0] = parent_class.resource_name
      else
        namespace[0] = @options.path || @options[:class].resource_name
      end
      if id = extract_id(instance, options, original_options)
        namespace << id
      end
      namespace.join("/")
    end
def generate_path ( * args ) options = Hashie :: Mash . new ( :with_id => true ) if args . last . is_a? ( Hash ) original_options = args . pop options . merge! ( original_options ) end instance = args . first namespace = @options [ :class ] . to_s . split ( "::" ) namespace . delete ( "ZendeskAPI" ) has_parent = namespace . size > 1 || ( options [ :with_parent ] && @options . parent ) if has_parent parent_class = @options . parent ? @options . parent . class : ZendeskAPI . get_class ( namespace [ 0 ] ) parent_namespace = build_parent_namespace ( parent_class , instance , options , original_options ) namespace [ 1 .. 1 ] = parent_namespace if parent_namespace namespace [ 0 ] = parent_class . resource_name else namespace [ 0 ] = @options . path || @options [ :class ] . resource_name end if id = extract_id ( instance , options , original_options ) namespace << id end namespace . join ( "/" ) end
Generate a path to the resource.
Generate a path to the resource .
args
<not_specific>