Class: TableStructure::Schema::Column::Attrs

Inherits:
Object
  • Object
show all
Defined in:
lib/table_structure/schema/column/attrs.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(definition) ⇒ Attrs

Returns a new instance of Attrs.



9
10
11
12
13
14
# File 'lib/table_structure/schema/column/attrs.rb', line 9

def initialize(definition)
  @name = definition[:name]
  @keys = optimize_size([definition[:key]].flatten, definition[:size])
  @value = definition[:value]
  @size = definition[:size]
end

Instance Attribute Details

#keysObject (readonly)

Returns the value of attribute keys.



7
8
9
# File 'lib/table_structure/schema/column/attrs.rb', line 7

def keys
  @keys
end

#sizeObject (readonly)

Returns the value of attribute size.



7
8
9
# File 'lib/table_structure/schema/column/attrs.rb', line 7

def size
  @size
end

Instance Method Details

#name(context, table_context) ⇒ Object



16
17
18
19
# File 'lib/table_structure/schema/column/attrs.rb', line 16

def name(context, table_context)
  name = Utils.evaluate_callable(@name, context, table_context)
  optimize_size(name, @size)
end

#value(context, table_context) ⇒ Object



21
22
23
24
# File 'lib/table_structure/schema/column/attrs.rb', line 21

def value(context, table_context)
  value = Utils.evaluate_callable(@value, context, table_context)
  optimize_size(value, @size)
end