Class: HasHelpers::Dataset

Inherits:
Object
  • Object
show all
Includes:
Attributes, UIAttributes
Defined in:
lib/has_helpers/utils/dataset.rb

Instance Attribute Summary collapse

Attributes included from UIAttributes::HTMLAttributes

#skin

Instance Method Summary collapse

Methods included from Attributes::GuardedAttributes

included

Methods included from UIAttributes::HTMLAttributes

#raw_html_attrs

Methods included from Attributes

included

Instance Attribute Details

#dataObject



30
31
32
# File 'lib/has_helpers/utils/dataset.rb', line 30

def data
  @data ||= []
end

#tableObject

Returns the value of attribute table.



9
10
11
# File 'lib/has_helpers/utils/dataset.rb', line 9

def table
  @table
end

Instance Method Details

#to_renderableObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/has_helpers/utils/dataset.rb', line 12

def to_renderable
  Container.new(
    renderable: data.map do |row|
      Container.new(
        renderable: row.map do |cell|
          Container.new(
            renderable: cell,
            tag: :span,
            skin: "cell"
          )
        end,
        skin: "row"
      )
    end,
    skin: [*skin, "dataset", *(table && "table")].join(" ")
  )
end