Class: Icss::Meta::RecordSchema

Inherits:
SimpleSchema show all
Includes:
Gorillib::Hashlike, Gorillib::Hashlike::Keys, RecordModel, ReceiverModel::ActsAsHash
Defined in:
lib/icss/type.rb,
lib/icss/type/record_schema.rb

Direct Known Subclasses

ErrorSchema

Instance Attribute Summary

Attributes inherited from NamedSchema

#is_core

Instance Method Summary collapse

Methods included from ReceiverModel::ActsAsHash

#[], #[]=, #attributes, #delete, included, #keys

Methods included from RecordModel

#attr_set?, included, #receive!, #to_zaml

Methods inherited from SimpleSchema

#basename=, #fullname, #parent_klass, #parent_metamodels, #receive_basename

Methods inherited from NamedSchema

#is_core?, receive

Instance Method Details

#attrs_to_inscribeObject



42
43
44
# File 'lib/icss/type/record_schema.rb', line 42

def attrs_to_inscribe
  [ :doc, :fullname, :is_a, :_domain_id_field, :_doc_hints ]
end

#model_klassObject



28
29
30
31
32
33
34
35
36
# File 'lib/icss/type/record_schema.rb', line 28

def model_klass
  return @model_klass if @model_klass
  super
  @model_klass.class_eval{ include(::Icss::Meta::RecordModel)}
  self.fields.each do |field_schema|
    @model_klass.field(field_schema[:name], field_schema[:type], field_schema)
  end
  @model_klass
end

#receive_fields(flds) ⇒ Object



38
39
40
# File 'lib/icss/type/record_schema.rb', line 38

def receive_fields(flds)
  super(flds.map(&:symbolize_keys!))
end

#to_hashObject



17
18
19
20
21
22
23
24
25
26
# File 'lib/icss/type/record_schema.rb', line 17

def to_hash
  {
    :name      => basename,
    :namespace => namespace,
    :type      => type,
    :is_a      => (respond_to?(:is_a) ? is_a : []),
    :doc       => doc,
    :fields    => fields.map(&:to_schema),
   }.compact_blank
end

#typeObject



15
# File 'lib/icss/type/record_schema.rb', line 15

def type() :record ; end