Module: JustimmoClient::Utils Private

Included in:
JustimmoClient, V1, V1::EmployeeInterface, V1::JSON, V1::JustimmoBase, V1::RealtyInterface, V1::XML
Defined in:
lib/justimmo_client/core/utils.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Useful utility methods

API:

  • private

Instance Method Summary collapse

Instance Method Details

#api(name) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



22
23
24
# File 'lib/justimmo_client/core/utils.rb', line 22

def api(name)
  "JustimmoClient::#{name.to_s.classify}".constantize
end

#autoload_dir(path) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



9
10
11
12
13
14
15
16
# File 'lib/justimmo_client/core/utils.rb', line 9

def autoload_dir(path)
  dirname = File.dirname(path)

  Dir[path].each do |f|
    basename = File.basename(f, ".rb")
    send :autoload, basename.classify, File.join(dirname, basename)
  end
end

#interface(name) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



38
39
40
# File 'lib/justimmo_client/core/utils.rb', line 38

def interface(name)
  versioned_api("#{name.to_s.classify}Interface")
end

#model(name) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



30
31
32
# File 'lib/justimmo_client/core/utils.rb', line 30

def model(name)
  versioned_api(name.to_s.classify)
end

#representer(name, type = :xml) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



26
27
28
# File 'lib/justimmo_client/core/utils.rb', line 26

def representer(name, type = :xml)
  versioned_api(type.to_s.classify, "#{name.to_s.classify}Representer")
end

#request(name) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



34
35
36
# File 'lib/justimmo_client/core/utils.rb', line 34

def request(name)
  versioned_api("#{name.to_s.classify}Request")
end

#translate(text) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



42
43
44
45
46
# File 'lib/justimmo_client/core/utils.rb', line 42

def translate(text)
  I18n.translate("justimmo_client.#{text}", raise: true)
rescue I18n::MissingTranslationData
  text.split(".").last.capitalize
end

#versioned_api(*name) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

API:

  • private



18
19
20
# File 'lib/justimmo_client/core/utils.rb', line 18

def versioned_api(*name)
  (["JustimmoClient::V#{JustimmoClient::Config.api_ver}"] + name).join("::").constantize
end