Method: Chef::Node#method_missing
- Defined in:
- lib/chef/sugar/node.rb
#method_missing(m, *args, &block) ⇒ nil, Object
Provide a nice DSL for defining attributes. method_missing is called on all the attribute names. For more information on how to use the DSL, see the class-level documentation.
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/chef/sugar/node.rb', line 161 def method_missing(m, *args, &block) old_method_missing(m, *args, &block) rescue NoMethodError # The Node Attribute's key is the method name key = m.to_s # If arguments are passed in, set node attribute with args as the value if args.size > 0 vivified[key] = args.size == 1 ? args.first : args return nil # If no arguments are passed in, attempt to access corresponding attribute else deep_key = current_namespace.dup << key return deep_fetch!(*deep_key) end end |