Method: Chef::Resource#as_json
- Defined in:
- lib/chef/resource.rb
#as_json(*a) ⇒ Object
as_json does most of the to_json heavy lifted. It exists here in case activesupport is loaded. activesupport will call as_json and skip over to_json. This ensure json is encoded as expected
702 703 704 705 706 707 708 709 710 711 712 |
# File 'lib/chef/resource.rb', line 702 def as_json(*a) safe_ivars = instance_variables.map(&:to_sym) - FORBIDDEN_IVARS instance_vars = {} safe_ivars.each do |iv| instance_vars[iv.to_s.sub(/^@/, "")] = instance_variable_get(iv) end { "json_class" => self.class.name, "instance_vars" => instance_vars, } end |