Class: Icss::Meta::HashSchema
- Inherits:
-
StructuredSchema
- Object
- NamedSchema
- StructuredSchema
- Icss::Meta::HashSchema
- Defined in:
- lib/icss/type/structured_schema.rb,
lib/icss/type.rb
Overview
HashSchema describes an Avro Map type (which corresponds to a Ruby Hash).
Hashes use the type name “hash” (or “map”) and support one attribute:
-
values: the schema of the map’s values. Avro Map keys are assumed to be strings.
@example, a map from string to long is declared with:
{"type": "map", "values": "long"}
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
193 194 195 196 197 198 199 |
# File 'lib/icss/type/structured_schema.rb', line 193 def self.receive(hsh) hsh.symbolize_keys! warn "Suspicious key :items - hash schema takes :values (#{hsh})" if hsh.has_key?(:items) val = super(hsh) raise ArgumentError, "Value Factory is no good: #{hsh} - #{val._schema}" if val.values.blank? val end |
Instance Method Details
#fullname ⇒ Object
187 188 189 190 191 |
# File 'lib/icss/type/structured_schema.rb', line 187 def fullname return @fullname if @fullname slug = (Type.klassname_for(values) || object_id.to_s).gsub(/^:*Icss:+/, '').gsub(/:+/, 'Dot') self.fullname = "HashOf#{slug}" end |
#to_hash ⇒ Object
200 201 202 |
# File 'lib/icss/type/structured_schema.rb', line 200 def to_hash { :type => :map, :values => Type.schema_for(values) } end |
#type ⇒ Object
203 |
# File 'lib/icss/type/structured_schema.rb', line 203 def type() :map ; end |