lib/slack_messaging/config.rb in slack_messaging-3.1.0 vs lib/slack_messaging/config.rb in slack_messaging-3.1.1

- old
+ new

@@ -1,28 +1,30 @@ # frozen_string_literal: true module SlackMessaging class Config - def self.config - config_data.to_hash - end + class << self + def method_missing(method, args = false) + config_data.send(method, args) + end - def self.load(path) - load_config(path) - config - end + def load(path) + load_config(path) + config + end - def self.config_data - @config_data ||= Hashie::Mash.new - end + private def config + config_data.to_hash + end - def self.method_missing(method, args = false) - config_data.send(method, args) - end + private def config_data + @config_data ||= Hashie::Mash.new + end - def self.load_config(file) - raise MissingConfig, "Missing configuration file: #{file}" unless File.exist?(file) + private def load_config(file) + raise StandardError, "Missing configuration file: #{file}" unless File.exist?(file) - YAML.load_file(file).each { |key, value| config_data.assign_property(key, value) } + YAML.load_file(file).each { |key, value| config_data.assign_property(key, value) } + end end end end