Method: FactoryForm::Form#to_json

Defined in:
lib/factoryform/form.rb

#to_jsonObject



61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/factoryform/form.rb', line 61

def to_json
  fields = Array.new
  @fields.each do |f|
    attributes = f.instance_variables.map{|a| a.gsub("@","")}
    attributes_hash = {}
    attributes.each do |a|
      attributes_hash[a] = f.send(a)
    end
    fields << {f.class.name => attributes_hash }  
  end
  fields
  fields.to_json
end