Module: Configster
- Defined in:
- lib/configster/version.rb,
lib/configster/configster.rb
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- VERSION =
"0.0.3"
Class Method Summary collapse
- .config_for(klass) ⇒ Object
- .included(base) ⇒ Object
-
.load!(configster_config) ⇒ Object
= Core Configster Methods = ===========================.
- .raw_config_for(klass) ⇒ Object
Instance Method Summary collapse
-
#configster ⇒ Object
= Instance Methods for the Receiving Class = ============================================.
- #raw_configster ⇒ Object
Class Method Details
.config_for(klass) ⇒ Object
52 53 54 55 |
# File 'lib/configster/configster.rb', line 52 def self.config_for(klass) klass_config = @configster_config[klass.to_s] klass_config ? OpenStruct.new(klass_config).freeze : nil end |
.included(base) ⇒ Object
16 17 18 |
# File 'lib/configster/configster.rb', line 16 def self.included(base) base.extend(ClassMethods) end |
.load!(configster_config) ⇒ Object
Core Configster Methods =
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/configster/configster.rb', line 34 def self.load!(configster_config) @configster_config ||= { } case configster_config when Hash @configster_config.merge!(configster_config) when String if File.directory?(configster_config) Dir.glob(File.join(configster_config, "*.yml")).each do |file| @configster_config.merge!(YAML.load_file(file)) end elsif File.exists?(configster_config) @configster_config.merge!(YAML.load_file(configster_config)) else raise "Unable to locate #{configster_config}" end end end |
.raw_config_for(klass) ⇒ Object
57 58 59 |
# File 'lib/configster/configster.rb', line 57 def self.raw_config_for(klass) @configster_config[klass.to_s] end |
Instance Method Details
#configster ⇒ Object
Instance Methods for the Receiving Class =
23 24 25 |
# File 'lib/configster/configster.rb', line 23 def configster self.class.configster end |
#raw_configster ⇒ Object
27 28 29 |
# File 'lib/configster/configster.rb', line 27 def raw_configster self.class.raw_configster end |