Class: MekariSso::Config
- Inherits:
-
Object
- Object
- MekariSso::Config
- Defined in:
- lib/config.rb
Direct Known Subclasses
AddUserCompany, City, Company, CompanyOfUser, CompanyRegister, CompanyRemove, List, UserAvatar, UserExistence, UserRegister, UserVerifyEmail, ValidateUserPassword
Instance Attribute Summary collapse
-
#accept_language ⇒ Object
Returns the value of attribute accept_language.
-
#access_token ⇒ Object
Returns the value of attribute access_token.
-
#base_url ⇒ Object
Returns the value of attribute base_url.
-
#client_id ⇒ Object
Returns the value of attribute client_id.
-
#client_secret ⇒ Object
Returns the value of attribute client_secret.
Instance Method Summary collapse
- #apply(hash) ⇒ Object
- #available_keys ⇒ Object
-
#initialize(options = nil) ⇒ Config
constructor
AVAILABLE_KEYS = %i[client_id client_secret base_url access_token accept_language].freeze.
- #validate_required! ⇒ Object
Constructor Details
#initialize(options = nil) ⇒ Config
AVAILABLE_KEYS = %i[client_id client_secret base_url access_token accept_language].freeze
9 10 11 |
# File 'lib/config.rb', line 9 def initialize( = nil) apply() if end |
Instance Attribute Details
#accept_language ⇒ Object
Returns the value of attribute accept_language.
5 6 7 |
# File 'lib/config.rb', line 5 def accept_language @accept_language end |
#access_token ⇒ Object
Returns the value of attribute access_token.
5 6 7 |
# File 'lib/config.rb', line 5 def access_token @access_token end |
#base_url ⇒ Object
Returns the value of attribute base_url.
5 6 7 |
# File 'lib/config.rb', line 5 def base_url @base_url end |
#client_id ⇒ Object
Returns the value of attribute client_id.
5 6 7 |
# File 'lib/config.rb', line 5 def client_id @client_id end |
#client_secret ⇒ Object
Returns the value of attribute client_secret.
5 6 7 |
# File 'lib/config.rb', line 5 def client_secret @client_secret end |
Instance Method Details
#apply(hash) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/config.rb', line 17 def apply(hash) hash.each do |key, value| unless available_keys.include?(key.to_s.to_sym) raise ArgumentError, "Unknown option #{key.inspect}, available keys: #{available_keys.map(&:inspect).join(', ')}" end send(:"#{key}=", value) end end |
#available_keys ⇒ Object
13 14 15 |
# File 'lib/config.rb', line 13 def available_keys %i[client_id client_secret base_url access_token accept_language] end |
#validate_required! ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/config.rb', line 29 def validate_required! unless @client_id.present? raise ArgumentError, "Params client_id is required options" end unless @client_secret.present? raise ArgumentError, "Params client_secret is required options" end unless @base_url.present? raise ArgumentError, "Params base_url is required options" end end |