Class: Icss::Meta::RecordField

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

Constant Summary collapse

ALLOWED_ORDERS =
%w[ascending descending ignore].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ReceiverModel::ActiveModelShim

#destroyed?, #errors, included, #new_record?, #to_model

Methods included from ReceiverModel

included, #tree_merge!

Methods included from ReceiverModel::ActsAsTuple

included, #to_tuple

Methods included from RecordModel

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

Methods included from ReceiverModel::ActsAsLoadable

#merge_from_file!

Methods included from ReceiverModel::ActsAsHash

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

Instance Attribute Details

#parentObject

Returns the value of attribute parent.



27
28
29
# File 'lib/icss/type/record_field.rb', line 27

def parent
  @parent
end

Instance Method Details

#is_reference?Boolean

is the field a reference to a named type (true), or an inline schema (false)?

Returns:



47
# File 'lib/icss/type/record_field.rb', line 47

def is_reference?() @is_reference ; end

#merge(hsh) ⇒ Object

Hack hack – makes it so fields go thru the receiver door when merged in RecordType



60
61
62
# File 'lib/icss/type/record_field.rb', line 60

def merge(hsh)
  dup.receive!(hsh)
end

#orderObject

Order is defined by the avro spec



65
# File 'lib/icss/type/record_field.rb', line 65

def order()           @order || 'ascending' ; end

#order_directionObject



66
# File 'lib/icss/type/record_field.rb', line 66

def order_direction() case order when 'ascending' then 1 when 'descending' then -1 else 0 ; end ; end

#to_hashObject



49
50
51
52
53
54
# File 'lib/icss/type/record_field.rb', line 49

def to_hash()
  hsh = super
  hsh = hsh.merge({ :type => (is_reference? ? type.fullname : Type.schema_for(type)) })
  hsh.delete(:_extra_params)
  hsh
end

#to_schemaObject



55
56
57
# File 'lib/icss/type/record_field.rb', line 55

def to_schema
  to_hash
end