Class: TableStructure::Table::ContextBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/table_structure/table/context_builder.rb

Defined Under Namespace

Classes: ContextBuildable

Class Method Summary collapse

Class Method Details

.create_module(builders, apply_to_name: true, apply_to_value: true, context:) {|ContextBuildable.new(methods)| ... } ⇒ Object

Yields:



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/table_structure/table/context_builder.rb', line 14

def create_module(
  builders,
  apply_to_name: true,
  apply_to_value: true,
  context:
)
  return if builders.empty?

  header_builder = builders[:header] # TODO: Change not to use keyword of `header`
  row_builder = builders[:row]

  methods = {}

  if apply_to_name && builders.key?(:header)
    methods[:header] = create_method(builders[:header])
  end

  if apply_to_value && builders.key?(:row)
    methods[:data] = create_method(builders[:row])
  end

  yield ContextBuildable.new(methods)
end