Class: Carpenter::Model::Field

Inherits:
Object
  • Object
show all
Defined in:
lib/struct_declaration.rb,
lib/carpenter/model/field.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(field_definition, key) ⇒ Field

Returns a new instance of Field.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/carpenter/model/field.rb', line 7

def initialize(field_definition, key)
  @name = field_definition.name
  @type = field_definition.type
  @type_caster = Carpenter::Model::TypeCaster[@type]
  @key = [key, @name].join(':')
  @definition = field_definition

  options = field_definition.options
  @force = options[:force].nil? ? false : options[:force]
  @store = options[:store].nil? ? false : options[:store]
  @default = options[:default]
  @options = options

  extend Carpenter::Model::Strategy[@type]
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



5
6
7
# File 'lib/carpenter/model/field.rb', line 5

def key
  @key
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/carpenter/model/field.rb', line 5

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/carpenter/model/field.rb', line 5

def options
  @options
end

#typeObject (readonly)

Returns the value of attribute type.



5
6
7
# File 'lib/carpenter/model/field.rb', line 5

def type
  @type
end