Module: Teachable::Jg::Configuration
- Included in:
- Teachable::Jg
- Defined in:
- lib/teachable/jg/configuration.rb
Constant Summary collapse
- VALID_CONNECTION_KEYS =
[:method, :status_message, :delivered].freeze
- VALID_OPTIONS_KEYS =
[:format, :headers, :authorized].freeze
- VALID_CONFIG_KEYS =
VALID_CONNECTION_KEYS + VALID_OPTIONS_KEYS
- DEFAULT_ENDPOINT =
"http://secure.localhost.com:3000/users"
- CURRENT_USER_ENDPOINT =
"http://secure.localhost.com:3000/api/users/current_user/edit"
- ORDERS_ENDPOINT =
"http://secure.localhost.com:3000/api/orders"
- DEFAULT_HEADERS =
{ "Content-Type" => "application/json", "Accept" => "application/json" }
- DEFAULT_METHOD =
:post
- DEFAULT_FORMAT =
:json
- DEFAULT_USER_AGENT =
"Teachable Mock API Ruby Gem #{Teachable::Jg::VERSION}".freeze
- DEFAULT_DELIVERED =
false
- DEFAULT_AUTHORIZED =
false
- DEFAULT_STATUS_MESSAGE =
""
Class Method Summary collapse
-
.extended(base) ⇒ Object
Make sure we have the default values set when we get ‘extended’.
Instance Method Summary collapse
Class Method Details
.extended(base) ⇒ Object
Make sure we have the default values set when we get ‘extended’
29 30 31 |
# File 'lib/teachable/jg/configuration.rb', line 29 def self.extended(base) base.reset end |
Instance Method Details
#configure {|_self| ... } ⇒ Object
49 50 51 |
# File 'lib/teachable/jg/configuration.rb', line 49 def configure yield self end |
#options ⇒ Object
33 34 35 36 37 38 |
# File 'lib/teachable/jg/configuration.rb', line 33 def Hash[ * VALID_CONFIG_KEYS.map do |key| self.reset [key, send(key)] end.flatten ] end |
#reset ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/teachable/jg/configuration.rb', line 40 def reset self.headers = DEFAULT_HEADERS self.method = DEFAULT_METHOD self.format = DEFAULT_FORMAT self.delivered = DEFAULT_DELIVERED self. = DEFAULT_STATUS_MESSAGE self. = DEFAULT_AUTHORIZED end |