Module: ConfigPlus::Helper
- Defined in:
- lib/config_plus/helper.rb
Class Method Summary collapse
Class Method Details
.config_for(object, config) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/config_plus/helper.rb', line 4 def config_for(object, config) configs = matched_configs(object, config) return configs.first if configs.size <= 1 if configs.all? {|c| c.is_a? Hash } configs.inject(::ConfigPlus::Node.new) {|h, conf| ::ConfigPlus::Merger.merge(h, conf) } else configs.inject([]) {|a, conf| a << conf } end end |
.underscore(name) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/config_plus/helper.rb', line 17 def underscore(name) name.gsub(/::/, '.') .gsub(/((\A|\b)([A-Z]+))|([A-Z]+)/) do next $3.downcase if $3 "_#{$4.downcase}" end end |