module Chef::ResourceCollection::ResourceCollectionSerialization

Public Class Methods

included(base) click to toggle source
# File lib/chef/resource_collection/resource_collection_serialization.rb, line 42
def self.included(base)
  base.extend(ClassMethods)
end

Public Instance Methods

is_chef_resource!(arg) click to toggle source
# File lib/chef/resource_collection/resource_collection_serialization.rb, line 60
def is_chef_resource!(arg)
  unless arg.kind_of?(Chef::Resource)
    raise ArgumentError, "Cannot insert a #{arg.class} into a resource collection: must be a subclass of Chef::Resource"
  end
  true
end
to_h() click to toggle source

Serialize this object as a hash

# File lib/chef/resource_collection/resource_collection_serialization.rb, line 25
def to_h
  instance_vars = Hash.new
  instance_variables.each do |iv|
    instance_vars[iv] = instance_variable_get(iv)
  end
  {
      "json_class" => self.class.name,
      "instance_vars" => instance_vars,
  }
end
Also aliased as: to_hash
to_hash()
Alias for: to_h
to_json(*a) click to toggle source
# File lib/chef/resource_collection/resource_collection_serialization.rb, line 38
def to_json(*a)
  Chef::JSONCompat.to_json(to_hash, *a)
end