Class: TableStructure::Schema::Definition
- Inherits:
-
Object
- Object
- TableStructure::Schema::Definition
- Defined in:
- lib/table_structure/schema/definition.rb,
lib/table_structure/schema/definition/error.rb,
lib/table_structure/schema/definition/validator.rb
Defined Under Namespace
Constant Summary collapse
- DEFAULT_ATTRS =
{ name: nil, key: nil, value: nil, size: nil }.freeze
- DEFAULT_SIZE =
1
Instance Method Summary collapse
- #compile(context = nil) ⇒ Object
-
#initialize(definitions, options) ⇒ Definition
constructor
A new instance of Definition.
Constructor Details
#initialize(definitions, options) ⇒ Definition
Returns a new instance of Definition.
15 16 17 18 |
# File 'lib/table_structure/schema/definition.rb', line 15 def initialize(definitions, ) @definitions = definitions @options = end |
Instance Method Details
#compile(context = nil) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/table_structure/schema/definition.rb', line 20 def compile(context = nil) @definitions .map { |definition| Utils.evaluate_callable(definition, context) } .map.with_index do |definition, i| validator = Validator.new(i, @options) [definition] .flatten .map do |definition| definition = DEFAULT_ATTRS.merge(definition) validator.validate(definition) definition[:size] = determine_size(definition) definition end end .flatten end |