Class: Lono::Registration::Base

Inherits:
Object
  • Object
show all
Extended by:
Memoist
Defined in:
lib/lono/registration/base.rb

Direct Known Subclasses

Temp, User

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Base

Returns a new instance of Base.



5
6
7
# File 'lib/lono/registration/base.rb', line 5

def initialize(options={})
  @options = options
end

Instance Method Details

#apiObject



28
29
30
# File 'lib/lono/registration/base.rb', line 28

def api
  Lono::Api::Client.new
end

#get_temp_keyObject



16
17
18
19
20
# File 'lib/lono/registration/base.rb', line 16

def get_temp_key
  with_safety do
    api.temp_key # grab temp registration key
  end
end

#request_verification(info) ⇒ Object

Same api call for temp_key and registration_key



10
11
12
13
14
# File 'lib/lono/registration/base.rb', line 10

def request_verification(info)
  with_safety do
    api.verify(info)
  end
end

#say(msg) ⇒ Object



33
34
35
# File 'lib/lono/registration/base.rb', line 33

def say(msg)
  puts msg if @options[:cli]
end

#with_safetyObject



22
23
24
25
26
# File 'lib/lono/registration/base.rb', line 22

def with_safety
  yield
rescue Errno::ECONNREFUSED, Errno::EAFNOSUPPORT
  raise if Lono::API != Lono::API_DEFAULT
end