Class: Device::Setting
- Inherits:
-
Object
- Object
- Device::Setting
- Defined in:
- lib/device/setting.rb
Constant Summary collapse
- FILE_PATH =
"./main/config.dat"- HOST_PRODUCTION =
"switch.cloudwalk.io"- HOST_STAGING =
"switch-staging.cloudwalk.io"- PORT_TCP =
"31415"- PORT_TCP_SSL =
"31416"- DEFAULT =
{ "host" => HOST_PRODUCTION, "host_port" => PORT_TCP_SSL, "ssl" => "1", "user" => "", "password" => "", #WIFI "apn" => "", "sim_pim" => "", "sim_slot" => "0", "sim_dual" => "0", "authentication" => "", #WIFI "essid" => "", #WIFI "bssid" => "", #WIFI "cipher" => "", #WIFI "mode" => "", #WIFI "channel" => "", #WIFI "media" => "", "ip" => "", "gateway" => "", "dns1" => "", "dns2" => "", "subnet" => "", "phone" => "", "modem_speed" => "", "logical_number" => "", "network_configured" => "", "touchscreen" => "", "environment" => "", "attach_gprs_timeout" => "", "attach_tries" => "", "notification_socket_timeout" => "", # Period to create fiber "notification_timeout" => "", # Time to wait message to read "notification_interval" => "", # Check interval "notification_stream_timeout" => "", # Time to wait stream message to read "cw_switch_version" => "", "cw_pos_timezone" => "", "tcp_recv_timeout" => "14", "iso8583_recv_tries" => "0", "iso8583_send_tries" => "0", "crypto_dukpt_slot" => "", "ctls" => "", "locale" => "en", "company_name" => "" }
Class Method Summary collapse
- .check_environment! ⇒ Object
- .method_missing(method, *args, &block) ⇒ Object
- .production? ⇒ Boolean
- .setup ⇒ Object
- .staging? ⇒ Boolean
- .to_production! ⇒ Object
- .to_staging! ⇒ Object
- .update_attributes(*args) ⇒ Object
Class Method Details
.check_environment! ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/device/setting.rb', line 61 def self.check_environment! if self.staging? self.to_staging! else self.to_production! end end |
.method_missing(method, *args, &block) ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/device/setting.rb', line 97 def self.method_missing(method, *args, &block) setup unless @file param = method.to_s if @file[param] @file[param] elsif (param[-1..-1] == "=" && @file[param[0..-2]]) @file[param[0..-2]] = args.first else super end end |
.production? ⇒ Boolean
69 70 71 |
# File 'lib/device/setting.rb', line 69 def self.production? self.environment == "production" end |
.setup ⇒ Object
55 56 57 58 59 |
# File 'lib/device/setting.rb', line 55 def self.setup @file = FileDb.new(FILE_PATH, DEFAULT) self.check_environment! @file end |
.staging? ⇒ Boolean
73 74 75 |
# File 'lib/device/setting.rb', line 73 def self.staging? self.environment == "staging" end |
.to_production! ⇒ Object
77 78 79 80 81 82 83 |
# File 'lib/device/setting.rb', line 77 def self.to_production! if self.environment != "production" @file.update_attributes("company_name" => "", "environment" => "production", "host" => HOST_PRODUCTION) return true end false end |
.to_staging! ⇒ Object
85 86 87 88 89 90 91 |
# File 'lib/device/setting.rb', line 85 def self.to_staging! if self.environment != "staging" @file.update_attributes("company_name" => "", "environment" => "staging", "host" => HOST_STAGING) return true end false end |
.update_attributes(*args) ⇒ Object
93 94 95 |
# File 'lib/device/setting.rb', line 93 def self.update_attributes(*args) @file.update_attributes(*args) end |