module MmJsonClient
Configure the environment so the gem works.
Constants
- VERSION
Public Class Methods
api_def_dir()
click to toggle source
# File lib/mm_json_client.rb, line 25 def api_def_dir return ENV['API_DEF_DIR'] if ENV['API_DEF_DIR'] default_api_def_dir end
default_api_def_dir()
click to toggle source
# File lib/mm_json_client.rb, line 30 def default_api_def_dir File.join(this_dir, 'mm_json_client', 'api_definitions') end
define_api_methods()
click to toggle source
# File lib/mm_json_client.rb, line 54 def define_api_methods method_file = File.join(api_def_dir, 'methods.json') all_methods = JSON.parse(File.read(method_file)) dynamic_methods(all_methods).each do |method, return_type| MmJsonClient::Client.define_api_method(method, return_type) end end
dynamic_methods(methods)
click to toggle source
# File lib/mm_json_client.rb, line 50 def dynamic_methods(methods) methods.reject { |k, _v| static_methods.include?(k) } end
initialize_environment()
click to toggle source
Dynamically load the enums, methods and types from the default api definitions or those put in the directory provided in the environment variable API_DEF_DIR.
# File lib/mm_json_client.rb, line 14 def self.initialize_environment load_type_data load_enum_data define_api_methods end
load_enum_data()
click to toggle source
# File lib/mm_json_client.rb, line 40 def load_enum_data enum_file = File.join(api_def_dir, 'enums.json') enums = JSON.parse(File.read(enum_file)) MmJsonClient::Enums::EnumFactory.load_enums(enums) end
load_type_data()
click to toggle source
# File lib/mm_json_client.rb, line 34 def load_type_data type_file = File.join(api_def_dir, 'types.json') types = JSON.parse(File.read(type_file)) MmJsonClient::TypeFactory.load_types(types) end
static_methods()
click to toggle source
# File lib/mm_json_client.rb, line 46 def static_methods %w(Login Logout) end
this_dir()
click to toggle source
# File lib/mm_json_client.rb, line 21 def this_dir File.dirname(File.expand_path(__FILE__)) end