Module: BlazerJsonAPI::Configuration

Included in:
BlazerJsonAPI
Defined in:
lib/blazer_json_api/configuration.rb

Constant Summary collapse

VALID_OPTIONS_KEYS =
%i[username password nesting_column_separator].freeze
DEFAULT_USERNAME =
nil
DEFAULT_PASSWORD =
nil
DEFAULT_NESTING_COLUMN_SEPARATOR =
'__'.freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



14
15
16
# File 'lib/blazer_json_api/configuration.rb', line 14

def self.extended(base)
  base.reset_config!
end

Instance Method Details

#configure {|_self| ... } ⇒ Object

Convenience method to allow configuration options to be set in a block e.g. in an initializer for the application

Yields:

  • (_self)

Yield Parameters:



20
21
22
# File 'lib/blazer_json_api/configuration.rb', line 20

def configure
  yield self
end

#credentials_provided?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/blazer_json_api/configuration.rb', line 24

def credentials_provided?
  username.present? && password.present?
end

#reset_config!Object



28
29
30
31
32
# File 'lib/blazer_json_api/configuration.rb', line 28

def reset_config!
  self.username     = DEFAULT_USERNAME
  self.password     = DEFAULT_PASSWORD
  self.nesting_column_separator  = DEFAULT_NESTING_COLUMN_SEPARATOR
end