class Toolhound::Client
Constants
- DB_TYPE_REGEX
Attributes
def projects
end attr_accessor :access_token, :client_id, :uid, :expiry, :me
def projects
end attr_accessor :access_token, :client_id, :uid, :expiry, :me
def projects
end attr_accessor :access_token, :client_id, :uid, :expiry, :me
def projects
end attr_accessor :access_token, :client_id, :uid, :expiry, :me
def projects
end attr_accessor :access_token, :client_id, :uid, :expiry, :me
Public Class Methods
# File lib/toolhound-ruby/client.rb, line 40 def initialize(options = {}) # Use options passed in, but fall back to module defaults Toolhound::Configurable.keys.each do |key| instance_variable_set(:"@#{key}", options[key] || Toolhound.instance_variable_get(:"@#{key}")) end sign_in if authenticatable? end
Public Instance Methods
# File lib/toolhound-ruby/client.rb, line 111 def inventory @inventory ||= Toolhound::Inventory.new(self) end
# File lib/toolhound-ruby/client.rb, line 115 def inventory_item @inventory_item ||= Toolhound::InventoryItem.new(self) end
# File lib/toolhound-ruby/client.rb, line 103 def job @job ||= Toolhound::Job.new(self) end
# File lib/toolhound-ruby/client.rb, line 141 def manufacturer @vendor ||= Toolhound::Manufacturer.new(self) end
Wrapper around Kernel#warn to print warnings unless TOOLHOUND_SILENT is set to true.
@return [nil]
# File lib/toolhound-ruby/client.rb, line 208 def nearmiss_warn(*message) unless ENV['TOOLHOUND_SILENT'] warn message end end
Set password for authentication
@param value [String] Toolhound-field password
# File lib/toolhound-ruby/client.rb, line 94 def password=(value) reset_connection @password = value end
# File lib/toolhound-ruby/client.rb, line 123 def project @project ||= Toolhound::Project.new(self) end
# File lib/toolhound-ruby/client.rb, line 144 def purchase_order @vendor ||= Toolhound::PurchaseOrder.new(self) end
# File lib/toolhound-ruby/client.rb, line 119 def purchase_receipt @purchase_receipt ||= Toolhound::PurchaseReceipt.new(self) end
# File lib/toolhound-ruby/client.rb, line 150 def query(query, options = {}) klass = self results = connection.execute(query) results.map do |row| transform_attributes(row) end end
# File lib/toolhound-ruby/client.rb, line 127 def rental @rental ||= Toolhound::Rental.new(self) end
# File lib/toolhound-ruby/client.rb, line 134 def rental_charge @rental_charge ||= Toolhound::RentalCharge.new(self) end
# File lib/toolhound-ruby/client.rb, line 131 def rental_item @rental_item ||= Toolhound::RentalItem.new(self) end
# File lib/toolhound-ruby/client.rb, line 99 def reset_connection @connection = nil end
Compares client options to a Hash of requested options
@param opts [Hash] Options to compare with current client options @return [Boolean]
# File lib/toolhound-ruby/client.rb, line 54 def same_options?(opts) opts.hash == options.hash end
# File lib/toolhound-ruby/client.rb, line 107 def transaction @transaction ||= Toolhound::Transaction.new(self) end
“SELECT MAX(dteStartDate) AS max_date, MIN(dteStartDate) AS min_date FROM tblRentalCharge WHERE intEntityID = 100044”
# File lib/toolhound-ruby/client.rb, line 185 def transform_attribute_key(key) # renamed = self.class.renamed_attributes # if renamed.include? key # renamed[key].to_sym # elsif key == self.class.primary_key # :id # else # # "varTransferReceiptPrefix" # word = key[3..key.length] # word.underscore.to_sym # end word = key if DB_TYPE_REGEX =~ key word = key[3..key.length] end underscore(word).to_sym end
# File lib/toolhound-ruby/client.rb, line 161 def transform_attributes(attrs) hash = {} attrs.each do |k, v| key = transform_attribute_key(k) if hash.include? key hash[:"#{key}1"] = v else hash[key] = v end end hash end
Set username for authentication
@param value [String] Toolhound-field username
# File lib/toolhound-ruby/client.rb, line 86 def username=(value) reset_connection @email = value end
# File lib/toolhound-ruby/client.rb, line 138 def vendor @vendor ||= Toolhound::Vendor.new(self) end