Module: Answers
- Defined in:
- lib/answers/error.rb,
lib/answers/answer.rb,
lib/answers/client.rb,
lib/answers/version.rb,
lib/answers/protocol.rb,
lib/answers/question.rb,
lib/answers/base_model.rb,
lib/answers-ruby-client.rb
Defined Under Namespace
Modules: Protocol Classes: Answer, BaseModel, Client, Error, Question
Constant Summary collapse
- VERSION =
'0.0.1'
Class Method Summary collapse
-
.client ⇒ Object
initialized client accessible from the Answers singleton.
- .client? ⇒ Boolean
- .init(config = {}) ⇒ Object
-
.reset! ⇒ Object
erases the current client, if one exists.
Class Method Details
.client ⇒ Object
initialized client accessible from the Answers singleton
37 38 39 40 41 42 43 |
# File 'lib/answers/client.rb', line 37 def self.client if !client? raise Answers::Error.new "Answers Platform API not initialized. Call Answers.init." end @@client end |
.client? ⇒ Boolean
21 22 23 24 25 26 |
# File 'lib/answers/client.rb', line 21 def self.client? return false if (defined?(@@client)).nil? return false if @@client.nil? true end |
.init(config = {}) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/answers/client.rb', line 8 def self.init(config = {}) # check env vars by default defaulted = { user_email: ENV['ANSWERS_USER_EMAIL'], user_token: ENV['ANSWERS_USER_TOKEN'] } # if credentials are passed, overwrite the defaults defaulted.merge!(config) # instantiate a client @@client = Client.new(config) end |
.reset! ⇒ Object
erases the current client, if one exists
29 30 31 32 33 34 |
# File 'lib/answers/client.rb', line 29 def self.reset! return if !client? #return if (defined?(@@client)).nil? @@client = nil return end |