Class: FixedWidthColumns::Library
- Inherits:
-
Aduki::Initializable
- Object
- Aduki::Initializable
- FixedWidthColumns::Library
- Defined in:
- lib/fixed_width_columns/library.rb
Instance Attribute Summary collapse
-
#config_root ⇒ Object
Returns the value of attribute config_root.
Instance Method Summary collapse
- #export_config_for(klass, name) ⇒ Object
- #export_configs_for(klass) ⇒ Object
- #load_export_configs_for(klass) ⇒ Object
Instance Attribute Details
#config_root ⇒ Object
Returns the value of attribute config_root.
5 6 7 |
# File 'lib/fixed_width_columns/library.rb', line 5 def config_root @config_root end |
Instance Method Details
#export_config_for(klass, name) ⇒ Object
8 9 10 |
# File 'lib/fixed_width_columns/library.rb', line 8 def export_config_for klass, name export_configs_for(klass).detect { |cfg| cfg.name == name } end |
#export_configs_for(klass) ⇒ Object
12 13 14 15 |
# File 'lib/fixed_width_columns/library.rb', line 12 def export_configs_for klass klass = klass.class_name if klass.is_a? Class export_configs[klass] ||= load_export_configs_for klass end |
#load_export_configs_for(klass) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/fixed_width_columns/library.rb', line 17 def load_export_configs_for klass path = File.join config_root, "#{klass}.yml" return [] unless File.exist?(path) cfgs = YAML::load File.read path cfgs.map { |k,v| FixedWidthColumns::Config.new v.merge("target" => klass, "name" => k) } end |