module Unobtainium::World::ClassMethods

Modules can have class methods, too, but it's a little more verbose to provide them.

Constants

DEFAULT_CONFIG_OPTIONS

Configuraiton loading options

Public Instance Methods

config_file() click to toggle source

@return [String] the config file path, defaulting to 'config/config.yml'

# File lib/unobtainium/world.rb, line 39
def config_file
  return ::Collapsium::Config.config_file
end
config_file=(name) click to toggle source

Set the configuration file

# File lib/unobtainium/world.rb, line 34
def config_file=(name)
  ::Collapsium::Config.config_file = name
end
extended(world) click to toggle source

… and when it's extended.

# File lib/unobtainium/world.rb, line 55
def extended(world)
  # :nocov:
  set_config_defaults

  world.extend(::Collapsium::Config)
  # :nocov:
end
included(klass) click to toggle source

In order for Unobtainium::World to include Collapsium::Config functionality, it has to be inherited when the former is included…

# File lib/unobtainium/world.rb, line 46
def included(klass)
  set_config_defaults

  klass.class_eval do
    include ::Collapsium::Config
  end
end
set_config_defaults() click to toggle source
# File lib/unobtainium/world.rb, line 63
def set_config_defaults
  # Override collapsium-config's default config path
  if ::Collapsium::Config.config_file == \
     ::Collapsium::Config::DEFAULT_CONFIG_PATH
    ::Collapsium::Config.config_file = 'config/config.yml'
  end

  if ::Collapsium::Config.config_options == \
     ::Collapsium::Config::DEFAULT_CONFIG_OPTIONS
    ::Collapsium::Config.config_options = DEFAULT_CONFIG_OPTIONS
  end
end