Class: ChefZero::ChefData::CookbookData::PretendCookbookMetadata

Inherits:
Hash
  • Object
show all
Defined in:
lib/chef_zero/chef_data/cookbook_data.rb

Overview

Handles loading configuration values from a Chef config file

Author:

Instance Method Summary collapse

Constructor Details

#initialize(cookbook) ⇒ PretendCookbookMetadata

Returns a new instance of PretendCookbookMetadata.

Parameters:

  • path (String)


178
179
180
181
182
183
184
# File 'lib/chef_zero/chef_data/cookbook_data.rb', line 178

def initialize(cookbook)
  name(cookbook.name)
  recipes(cookbook.fully_qualified_recipe_names)
  %w{attributes grouping dependencies supports recommendations suggestions conflicting providing replacing recipes}.each do |hash_arg|
    self[hash_arg.to_sym] = Mash.new
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(key, *values) ⇒ Object (private)



221
222
223
224
225
226
227
228
229
230
231
# File 'lib/chef_zero/chef_data/cookbook_data.rb', line 221

def method_missing(key, *values)
  if values.nil?
    self[key.to_sym]
  else
    if values.length > 1
      store key.to_sym, values
    else
      store key.to_sym, values.first
    end
  end
end

Instance Method Details

#from_json(json) ⇒ Object



186
187
188
# File 'lib/chef_zero/chef_data/cookbook_data.rb', line 186

def from_json(json)
  merge!(FFI_Yajl::Parser.parse(json))
end