Module: DataMapper::Persevere::JSONSupport::Model::Properties

Defined in:
lib/persevere_adapter/json_support/model/properties.rb

Instance Method Summary collapse

Instance Method Details

#to_json_hash(repository_name = default_repository_name) ⇒ Object

TODO: Add various options in.



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/persevere_adapter/json_support/model/properties.rb', line 7

def to_json_hash(repository_name = default_repository_name)
  schema_hash = super
  schema_hash['properties'] ||= {}
  
  # Handle properties
  properties.select { |prop| prop.field != 'id' }.each do |prop| 
    prop = Persevere.enhance(prop)
    schema_hash['properties'][prop.field] = prop.to_json_hash(repository_name) 
  end

  return schema_hash
end