Class: Chef::Expander::ChefCompatibleConfig
- Inherits:
-
Object
- Object
- Chef::Expander::ChefCompatibleConfig
- Defined in:
- lib/chef/expander/configuration.rb
Instance Attribute Summary collapse
-
#config_hash ⇒ Object
readonly
Returns the value of attribute config_hash.
Instance Method Summary collapse
-
#initialize ⇒ ChefCompatibleConfig
constructor
A new instance of ChefCompatibleConfig.
- #load(file) ⇒ Object
- #method_missing(method_name, *args, &block) ⇒ Object
Constructor Details
#initialize ⇒ ChefCompatibleConfig
Returns a new instance of ChefCompatibleConfig.
52 53 54 |
# File 'lib/chef/expander/configuration.rb', line 52 def initialize @config_hash = {} end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
61 62 63 64 65 66 67 68 69 |
# File 'lib/chef/expander/configuration.rb', line 61 def method_missing(method_name, *args, &block) if args.size == 1 @config_hash[method_name] = args.first elsif args.empty? @config_hash[method_name] or super else super end end |
Instance Attribute Details
#config_hash ⇒ Object (readonly)
Returns the value of attribute config_hash.
50 51 52 |
# File 'lib/chef/expander/configuration.rb', line 50 def config_hash @config_hash end |
Instance Method Details
#load(file) ⇒ Object
56 57 58 59 |
# File 'lib/chef/expander/configuration.rb', line 56 def load(file) file = File.(file) instance_eval(IO.read(file), file, 1) if File.readable?(file) end |