Module: Rasti::Model::Schema
- Defined in:
- lib/rasti/model/schema.rb
Class Method Summary collapse
- .register_type_serializer(type, serialized_type = nil, &block) ⇒ Object
- .serialize(model_class, visited = Set.new) ⇒ Object
Class Method Details
.register_type_serializer(type, serialized_type = nil, &block) ⇒ Object
6 7 8 |
# File 'lib/rasti/model/schema.rb', line 6 def register_type_serializer(type, serialized_type=nil, &block) type_serializers[type] = block || serialized_type end |
.serialize(model_class, visited = Set.new) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/rasti/model/schema.rb', line 10 def serialize(model_class, visited=Set.new) attributes = model_class.attributes.map do |attribute| serialize_attribute(attribute, visited).merge(name: attribute.name) end { model: model_class.name || model_class.to_s, attributes: attributes } end |