Class: Icss::Meta::ArraySchema
- Inherits:
-
StructuredSchema
- Object
- NamedSchema
- StructuredSchema
- Icss::Meta::ArraySchema
- Defined in:
- lib/icss/type/structured_schema.rb,
lib/icss/type.rb
Overview
ArraySchema describes an Array type (as opposed to ArrayType, which implements it)
Arrays use the type name “array” and support a single attribute:
-
items: the schema of the array’s items.
@example, an array of strings is declared with:
{"type": "array", "items": "string"}
Instance Attribute Summary
Attributes inherited from NamedSchema
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from NamedSchema
#attrs_to_inscribe, #is_core?, #model_klass
Methods included from ReceiverModel::ActsAsHash
#[], #[]=, #attributes, #delete, included, #keys
Methods included from RecordModel
#attr_set?, included, #receive!, #to_zaml
Class Method Details
.receive(hsh) ⇒ Object
156 157 158 159 160 161 162 |
# File 'lib/icss/type/structured_schema.rb', line 156 def self.receive(hsh) hsh.symbolize_keys! warn "Suspicious key :values - array schema takes :items (#{hsh})" if hsh.has_key?(:values) val = super(hsh) raise ArgumentError, "Items Factory is no good: #{hsh} - #{val._schema.to_hash}" if val.items.blank? val end |
Instance Method Details
#fullname ⇒ Object
150 151 152 153 154 |
# File 'lib/icss/type/structured_schema.rb', line 150 def fullname return @fullname if @fullname slug = (Type.klassname_for(items) || object_id.to_s).gsub(/^:*Icss:+/, '').gsub(/:+/, 'Dot') @fullname = "ArrayOf#{slug}" end |
#to_hash ⇒ Object
163 164 165 |
# File 'lib/icss/type/structured_schema.rb', line 163 def to_hash { :type => :array, :items => Type.schema_for(items) } end |
#type ⇒ Object
166 |
# File 'lib/icss/type/structured_schema.rb', line 166 def type() :array ; end |