class InvoiceCreator::ConfigReader

Public Class Methods

new() click to toggle source
# File lib/invoice_creator/config_reader.rb, line 9
def initialize
  @yaml = YAML.load_file(File.expand_path("../../../config.yml", __FILE__))
end

Public Instance Methods

data() click to toggle source
# File lib/invoice_creator/config_reader.rb, line 17
def data
  @data ||= OpenStruct.new(@yaml["data"])
end
method_missing(method, *args, &block) click to toggle source

Hacky way to avoid having to define a method for each of the config properties. Here just for fun and to make it easier to play around with the code. This causes undesireable downstream effects, i.e. calling `respond_to?(:anything)` would return true, which it's fine in this codebase/project

Calls superclass method
# File lib/invoice_creator/config_reader.rb, line 25
def method_missing(method, *args, &block)
  settings.public_send(method) || data.public_send(method) || super
end
respond_to_missing?(method_name, *args) click to toggle source
# File lib/invoice_creator/config_reader.rb, line 29
def respond_to_missing?(method_name, *args)
  true
end
settings() click to toggle source
# File lib/invoice_creator/config_reader.rb, line 13
def settings
  @settings ||= OpenStruct.new(@yaml["settings"])
end