Class: Icss::Meta::NamedSchema

Inherits:
Object
  • Object
show all
Includes:
Gorillib::Hashlike, RecordModel, ReceiverModel::ActsAsHash
Defined in:
lib/icss/type.rb,
lib/icss/type/structured_schema.rb

Overview

full definitions in type/structured_schema.rb and type/union_schema.rb

Direct Known Subclasses

SimpleSchema, StructuredSchema, UnionSchema

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ReceiverModel::ActsAsHash

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

Methods included from RecordModel

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

Instance Attribute Details

#is_coreObject

Returns the value of attribute is_core.



10
11
12
# File 'lib/icss/type/structured_schema.rb', line 10

def is_core
  @is_core
end

Class Method Details

.receive(schema) ⇒ Object



61
62
63
# File 'lib/icss/type/structured_schema.rb', line 61

def self.receive(schema)
  super(schema).model_klass
end

Instance Method Details

#attrs_to_inscribeObject



37
38
39
# File 'lib/icss/type/structured_schema.rb', line 37

def attrs_to_inscribe
  self.class.field_names
end

#is_core?Boolean

Returns:



33
34
35
# File 'lib/icss/type/structured_schema.rb', line 33

def is_core?
  !!is_core
end

#model_klassObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/icss/type/structured_schema.rb', line 41

def model_klass
  return @model_klass if @model_klass
  @model_klass = Icss::Meta::NamedType.get_model_klass(fullname, parent_klass||Object)
  model_type = @model_klass.singleton_class
  # inscribe attributes
  attrs_to_inscribe.each do |attr|
    val = self.send(attr) 
    model_type.class_eval{ define_method(attr){ val } }
  end
  schema_writer = self
  model_type.class_eval{ define_method(:_schema){ schema_writer } }
  # module inclusions
  parent_metamodels.each do |parent_metamodel|
    @model_klass.class_eval{ include parent_metamodel }
  end
  klass_metatypes.each{|mt| @model_klass.extend(mt) }
  @model_klass.metamodel if @model_klass.respond_to?(:metamodel)
  @model_klass
end

#to_hashObject



64
65
66
67
68
69
70
# File 'lib/icss/type/structured_schema.rb', line 64

def to_hash
  hsh = super
  hsh[:type] = type
  hsh[:name] = hsh.delete(:fullname)
  hsh.delete(:is_core)
  hsh
end