module Stalky # config object that will be globally accessible # as Stalky::Config class Config # same ol attr_accessor but applied to the Config class itself class << self; attr_accessor :qwerly_api_key, :rapleaf_api_key; end def initialize(&block) # pass the Config class into the given block yield Config if block_given? end end end # put this in something like config/initializers/stalky.rb Stalky::Config.new do |config| config.qwerly_api_key = "foo" config.rapleaf_api_key = "bar" end # displays 'foo' puts Stalky::Config.qwerly_api_key # displays 'bar' puts Stalky::Config.rapleaf_api_key