Class: MarketoChef::Configuration
- Inherits:
-
Object
- Object
- MarketoChef::Configuration
- Defined in:
- lib/marketo_chef/configuration.rb
Overview
Store and validate Marketo client configuration data
Constant Summary collapse
- FIELDS =
%i[host client_id client_secret campaign_id].freeze
Instance Attribute Summary collapse
-
#campaign_id ⇒ Object
Returns the value of attribute campaign_id.
-
#client_id ⇒ Object
Returns the value of attribute client_id.
-
#client_secret ⇒ Object
Returns the value of attribute client_secret.
-
#host ⇒ Object
Returns the value of attribute host.
Instance Method Summary collapse
-
#initialize(config = {}) ⇒ Configuration
constructor
A new instance of Configuration.
- #validate ⇒ Object
Constructor Details
#initialize(config = {}) ⇒ Configuration
Returns a new instance of Configuration.
25 26 27 28 29 |
# File 'lib/marketo_chef/configuration.rb', line 25 def initialize(config = {}) return unless config.any? config.map { |k, v| send("#{k}=", v) if FIELDS.include?(k) } end |
Instance Attribute Details
#campaign_id ⇒ Object
Returns the value of attribute campaign_id.
22 23 24 |
# File 'lib/marketo_chef/configuration.rb', line 22 def campaign_id @campaign_id end |
#client_id ⇒ Object
Returns the value of attribute client_id.
22 23 24 |
# File 'lib/marketo_chef/configuration.rb', line 22 def client_id @client_id end |
#client_secret ⇒ Object
Returns the value of attribute client_secret.
22 23 24 |
# File 'lib/marketo_chef/configuration.rb', line 22 def client_secret @client_secret end |
#host ⇒ Object
Returns the value of attribute host.
23 24 25 |
# File 'lib/marketo_chef/configuration.rb', line 23 def host @host end |
Instance Method Details
#validate ⇒ Object
39 40 41 42 43 44 |
# File 'lib/marketo_chef/configuration.rb', line 39 def validate missing = ->(f) { !instance_variable_defined?(:"@#{f}") } bomb = ->(f) { raise "Required Marketo configuration undefined: #{f}" } FIELDS.select(&missing).map(&bomb) end |