def to_h
attrs = []
rels = []
properties = []
pk_attrs = []
@attributes.each { |attr| attrs << attr.to_h }
@relationships.each { |rel| rels << rel.to_h }
@class_properties.each { |prop| properties << prop.name }
@primary_key_attributes.each { |attr| pk_attrs << attr.name }
property = {
'name' => @name,
'class_name' => @class_name,
'external_name' => @external_name,
'attributes' => attrs,
'class_properties' => properties,
'primary_key_attributes' => pk_attrs
}
property['relationships'] = rels unless rels.empty?
property
end