Module: Doodle::JSON::InstanceMethods

Defined in:
lib/doodle/json.rb

Instance Method Summary collapse

Instance Method Details

#to_json(*a) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/doodle/json.rb', line 7

def to_json(*a)
  # don't include default values
  values = doodle.key_values_without_defaults
  value_hash = Hash[*Doodle::Utils.flatten_first_level(values)]
  {
    'json_class'   => self.class.name,
    'data' => value_hash,
  }.to_json(*a)
end