Class: IntuitIdsAggcat::Core::Configuration
- Inherits:
-
Object
- Object
- IntuitIdsAggcat::Core::Configuration
- Defined in:
- lib/intuit_ids_aggcat/core/configuration.rb
Overview
A configuration object for the Intuit interface.
Configuring Credentials
In order to do anything with the AggCat services you will need to assign credentials. The simplest method is to assing your credentials into the default configuration:
AWS.config(:access_key_id => 'KEY', :secret_access_key => 'SECRET')
You can also export them into your environment and they will be picked up automatically:
export AWS_ACCESS_KEY_ID='YOUR_KEY_ID_HERE'
export AWS_SECRET_ACCESS_KEY='YOUR_SECRET_KEY_HERE'
Class Method Summary collapse
- .accepted_options ⇒ Object
- .add_option(name, default_value = nil, options = {}, &transform) ⇒ Object
Instance Method Summary collapse
-
#credentials ⇒ Hash
Returns a hash with your configured credentials.
-
#eql?(other) ⇒ Boolean
(also: #==)
Returns true if the two configuration objects have the same values.
-
#initialize(options = {}) ⇒ Configuration
constructor
Creates a new Configuration object.
- #inspect ⇒ Object
-
#to_h ⇒ Hash
(also: #to_hash)
Returns a hash of all configuration values.
- #with(options = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Configuration
Creates a new Configuration object.
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/intuit_ids_aggcat/core/configuration.rb', line 27 def initialize = {} @created = .delete(:__created__) || {} .each_pair do |opt_name, value| opt_name = opt_name.to_sym if self.class..include?(opt_name) supplied[opt_name] = value end end end |
Class Method Details
.accepted_options ⇒ Object
94 95 96 |
# File 'lib/intuit_ids_aggcat/core/configuration.rb', line 94 def @options ||= Set.new end |
.add_option(name, default_value = nil, options = {}, &transform) ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/intuit_ids_aggcat/core/configuration.rb', line 99 def add_option name, default_value = nil, = {}, &transform << name define_method(name) do |&default_override| value = if supplied.has_key?(name) supplied[name] elsif default_override default_override.call else default_value end transform ? transform.call(self, value) : value end alias_method("#{name}?", name) if [:boolean] end |
Instance Method Details
#credentials ⇒ Hash
Returns a hash with your configured credentials.
40 41 42 43 44 45 46 47 48 |
# File 'lib/intuit_ids_aggcat/core/configuration.rb', line 40 def credentials credentials = {} [:saml_idp_id, :user_id].each do |opt| if value = credential_provider.send(opt) credentials[opt] = value end end credentials end |
#eql?(other) ⇒ Boolean Also known as: ==
Returns true if the two configuration objects have the same values.
75 76 77 |
# File 'lib/intuit_ids_aggcat/core/configuration.rb', line 75 def eql? other other.is_a?(self.class) and self.supplied == other.supplied end |
#inspect ⇒ Object
81 82 83 |
# File 'lib/intuit_ids_aggcat/core/configuration.rb', line 81 def inspect "<#{self.class.name}>" end |
#to_h ⇒ Hash Also known as: to_hash
Returns a hash of all configuration values.
66 67 68 69 70 |
# File 'lib/intuit_ids_aggcat/core/configuration.rb', line 66 def to_h self.class..inject({}) do |h,k| h.merge(k => send(k)) end end |
#with(options = {}) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/intuit_ids_aggcat/core/configuration.rb', line 50 def with = {} # symbolize option keys = .inject({}) {|h,kv| h[kv.first.to_sym] = kv.last; h } values = supplied.merge() if supplied == values self # nothing changed else self.class.new(values.merge(:__created__ => @created.dup)) end end |