class ITGlue::Client::PathProcessor

Public Class Methods

new(asset_type, options = {}) click to toggle source

@param asset_type [Symbol|String] the pluralized asset type name @param options [Hash] valid options:

parent [ITGlue::Asset] the parent instance
id [Integer] the asset id
# File lib/itglue/client/path_processor.rb, line 12
def initialize(asset_type, options = {})
  @asset_type = asset_type
  @options = options
  @path_array = []
end
process(asset_type, options = {}) click to toggle source
# File lib/itglue/client/path_processor.rb, line 4
def self.process(asset_type, options = {})
  self.new(asset_type, options).path
end

Public Instance Methods

path() click to toggle source
# File lib/itglue/client/path_processor.rb, line 18
def path
  @path ||= path_array.unshift('').join('/')
end

Private Instance Methods

append_asset_type() click to toggle source
# File lib/itglue/client/path_processor.rb, line 47
def append_asset_type
  @path_array << @asset_type
end
append_id() click to toggle source
# File lib/itglue/client/path_processor.rb, line 51
def append_id
  @path_array << id
end
append_parent() click to toggle source
# File lib/itglue/client/path_processor.rb, line 41
def append_parent
  @path_array << parent.asset_type
  @path_array << parent.id
  @path_array << :relationships
end
id() click to toggle source
# File lib/itglue/client/path_processor.rb, line 28
def id
  @options[:id]
end
parent() click to toggle source
# File lib/itglue/client/path_processor.rb, line 24
def parent
  @options[:parent]
end
path_array() click to toggle source
# File lib/itglue/client/path_processor.rb, line 32
def path_array
  return @path_array if @processed
  append_parent if parent
  append_asset_type
  append_id if id
  @processed = true
  @path_array
end