Class: TaoUi::Components::Table::BaseBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/tao_ui/components/table/base_builder.rb

Direct Known Subclasses

BodyBuilder, HeadBuilder, RowBuilder, TableBuilder

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(view, options = {}) ⇒ BaseBuilder

Returns a new instance of BaseBuilder.



9
10
11
12
13
14
# File 'lib/tao_ui/components/table/base_builder.rb', line 9

def initialize view, options = {}
  @view = view
  @options = options
  @expandable = options[:expandable].presence || false
  @selectable = options[:selectable].presence || false
end

Instance Attribute Details

#expandableObject (readonly)

Returns the value of attribute expandable.



7
8
9
# File 'lib/tao_ui/components/table/base_builder.rb', line 7

def expandable
  @expandable
end

#optionsObject (readonly)

Returns the value of attribute options.



7
8
9
# File 'lib/tao_ui/components/table/base_builder.rb', line 7

def options
  @options
end

#selectableObject (readonly)

Returns the value of attribute selectable.



7
8
9
# File 'lib/tao_ui/components/table/base_builder.rb', line 7

def selectable
  @selectable
end

#viewObject (readonly)

Returns the value of attribute view.



7
8
9
# File 'lib/tao_ui/components/table/base_builder.rb', line 7

def view
  @view
end

Instance Method Details

#merge_options(options, other_options) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/tao_ui/components/table/base_builder.rb', line 16

def merge_options options, other_options
  options.merge(other_options) { |key, old_val, new_val|
    if key.to_s == 'class'
      old_val = old_val.split(' ') if old_val.is_a? String
      new_val = new_val.split(' ') if new_val.is_a? String
      Array(old_val) + Array(new_val)
    elsif old_val.is_a?(Hash) && old_val.is_a?(Hash)
      old_val.merge! new_val
    else
      new_val
    end
  }
end