class Object

Public Class Methods

read_token_from_file(path) click to toggle source
# File lib/realogy/app/models/data_sync.rb, line 147
def self.read_token_from_file path
  data = nil
  token = nil
  client = OAuth2::Client.new(
    ENV["REALOGY_CLIENT_ID"],
    ENV["REALOGY_CLIENT_SECRET"],
    token_url:  ENV["REALOGY_TOKEN_URL"]
  )
  if File.exists?(path)
    File.open(path) do |f|
      token = OAuth2::AccessToken.from_hash(client, JSON.parse(f.read))
    end
  end
  return token
end

Public Instance Methods

dig_for_array(*path) click to toggle source
# File lib/realogy/app/models/hash.rb, line 3
def dig_for_array(*path)
  (v = self.dig(*path)).is_a?(Array) ? v : nil
end
dig_for_boolean(*path) click to toggle source
# File lib/realogy/app/models/hash.rb, line 7
def dig_for_boolean(*path)
  (v = self.dig(*path)).to_s.upcase.eql?("TRUE") ? true : nil
end
dig_for_datetime(*path) click to toggle source
# File lib/realogy/app/models/hash.rb, line 11
def dig_for_datetime(*path)
  self.dig(*path).to_datetime rescue nil
end
dig_for_decimal(*path) click to toggle source
# File lib/realogy/app/models/hash.rb, line 15
def dig_for_decimal(*path)
  (v = self.dig(*path).to_f) != 0.0 ? v : nil
end
dig_for_hash(*path) click to toggle source
# File lib/realogy/app/models/hash.rb, line 19
def dig_for_hash(*path)
  (v = self.dig(*path)).is_a?(Hash) ? v : nil
end
dig_for_integer(*path) click to toggle source
# File lib/realogy/app/models/hash.rb, line 23
def dig_for_integer(*path)
  (v = self.dig(*path).to_i) != 0 ? v : nil
end
dig_for_string(*path) click to toggle source
# File lib/realogy/app/models/hash.rb, line 27
def dig_for_string(*path)
  (v = self.dig(*path)).to_s.present? ? (v.eql?("0") ? nil : v) : nil
end
save_token_to_file(path) click to toggle source
# File lib/realogy/app/models/data_sync.rb, line 163
def save_token_to_file path
  File.open(path, "w+") do |f|
    f << self.to_hash.to_json
  end
end