Class: Localeapp::KeyChecker
- Inherits:
-
Object
- Object
- Localeapp::KeyChecker
- Includes:
- ApiCall
- Defined in:
- lib/localeapp/key_checker.rb
Instance Method Summary collapse
Methods included from ApiCall
Instance Method Details
#check(key) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/localeapp/key_checker.rb', line 9 def check(key) if Localeapp.configuration.nil? # no config file yet Localeapp.configuration = Localeapp::Configuration.new Localeapp.configuration.host = ENV['LA_TEST_HOST'] if ENV['LA_TEST_HOST'] end Localeapp.configuration.api_key = key api_call :project, :success => :handle_success, :failure => :handle_failure, :max_connection_attempts => 1 if @checked [@ok, @data] else [false, "Error communicating with server"] end end |
#handle_failure(response) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/localeapp/key_checker.rb', line 33 def handle_failure(response) if response.code.to_i == 404 @checked = true @ok = false @data = {} else @checked = false end end |
#handle_success(response) ⇒ Object
27 28 29 30 31 |
# File 'lib/localeapp/key_checker.rb', line 27 def handle_success(response) @checked = true @ok = true @data = JSON.parse(response) end |