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, options) ⇒ Attrs

Returns a new instance of Attrs.



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

def initialize(definition, options)
  @name = definition[:name]
  @keys = optimize_size([definition[:key]].flatten, definition[:size])
  @value = definition[:value]
  @size = definition[:size]
  @options = options
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(header_context, table_context) ⇒ Object



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

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

#value(row_context, table_context) ⇒ Object



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

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