Module: Unobtainium::World::ClassMethods
- Included in:
- Unobtainium::World
- Defined in:
- lib/unobtainium/world.rb
Overview
Modules can have class methods, too, but it’s a little more verbose to provide them.
Constant Summary collapse
- DEFAULT_CONFIG_OPTIONS =
Configuraiton loading options
{ resolve_extensions: true, nonexistent_base: :extend, }.freeze
Instance Method Summary collapse
-
#config_file ⇒ String
The config file path, defaulting to ‘config/config.yml’.
-
#config_file=(name) ⇒ Object
Set the configuration file.
-
#extended(world) ⇒ Object
…
-
#included(klass) ⇒ Object
In order for Unobtainium::World to include Collapsium::Config functionality, it has to be inherited when the former is included…
- #set_config_defaults ⇒ Object
Instance Method Details
#config_file ⇒ String
Returns the config file path, defaulting to ‘config/config.yml’.
39 40 41 |
# File 'lib/unobtainium/world.rb', line 39 def config_file return ::Collapsium::Config.config_file end |
#config_file=(name) ⇒ Object
Set the configuration file
34 35 36 |
# File 'lib/unobtainium/world.rb', line 34 def config_file=(name) ::Collapsium::Config.config_file = name end |
#extended(world) ⇒ Object
… and when it’s extended.
55 56 57 58 59 60 61 |
# File 'lib/unobtainium/world.rb', line 55 def extended(world) # :nocov: set_config_defaults world.extend(::Collapsium::Config) # :nocov: end |
#included(klass) ⇒ Object
In order for Unobtainium::World to include Collapsium::Config functionality, it has to be inherited when the former is included…
46 47 48 49 50 51 52 |
# 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 ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 |
# 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. == \ ::Collapsium::Config::DEFAULT_CONFIG_OPTIONS ::Collapsium::Config. = DEFAULT_CONFIG_OPTIONS end end |