Class: ZapierRuby::Config
- Inherits:
-
Object
- Object
- ZapierRuby::Config
- Defined in:
- lib/zapier_ruby/config.rb
Instance Attribute Summary collapse
-
#base_uri ⇒ Object
Returns the value of attribute base_uri.
-
#enable_logging ⇒ Object
Returns the value of attribute enable_logging.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#web_hooks ⇒ Object
Returns the value of attribute web_hooks.
Instance Method Summary collapse
- #configure_with(path_to_yaml_file) ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #reconfigure(config = {}) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
5 6 7 8 9 10 |
# File 'lib/zapier_ruby/config.rb', line 5 def initialize self.base_uri = "https://zapier.com/hooks/catch/" self.web_hooks = { example_webhook: "webhook_id" } self.enable_logging = true self.logger = Logger.new(STDOUT) end |
Instance Attribute Details
#base_uri ⇒ Object
Returns the value of attribute base_uri.
3 4 5 |
# File 'lib/zapier_ruby/config.rb', line 3 def base_uri @base_uri end |
#enable_logging ⇒ Object
Returns the value of attribute enable_logging.
3 4 5 |
# File 'lib/zapier_ruby/config.rb', line 3 def enable_logging @enable_logging end |
#logger ⇒ Object
Returns the value of attribute logger.
3 4 5 |
# File 'lib/zapier_ruby/config.rb', line 3 def logger @logger end |
#web_hooks ⇒ Object
Returns the value of attribute web_hooks.
3 4 5 |
# File 'lib/zapier_ruby/config.rb', line 3 def web_hooks @web_hooks end |
Instance Method Details
#configure_with(path_to_yaml_file) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/zapier_ruby/config.rb', line 12 def configure_with(path_to_yaml_file) begin config_yaml = YAML::load(IO.read(path_to_yaml_file)) reconfigure(config_yaml) rescue StandardError => e logger.error "YAML configuration file cannot be loaded. Using defaults. Error :#{e.message}" return end end |
#reconfigure(config = {}) ⇒ Object
22 23 24 |
# File 'lib/zapier_ruby/config.rb', line 22 def reconfigure(config = {}) config.keys.select{|k| respond_to?("#{k}=")}.each{|k| self.send("#{k}=", config[k])} end |