Class: Dashboards::Table

Inherits:
Object
  • Object
show all
Defined in:
lib/dashboards/dsl/table.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name_or_options, options = {}) ⇒ Table

Returns a new instance of Table.



7
8
9
10
11
12
13
14
15
16
# File 'lib/dashboards/dsl/table.rb', line 7

def initialize(name_or_options, options = {})
  if name_or_options.is_a?(Hash)
    @name = nil
    options = name_or_options
  else
    @name = name_or_options
  end
  @data = options[:data] || options[:value]
  @options = options.except(:data, :value)
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



5
6
7
# File 'lib/dashboards/dsl/table.rb', line 5

def data
  @data
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/dashboards/dsl/table.rb', line 5

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/dashboards/dsl/table.rb', line 5

def options
  @options
end

Instance Method Details

#render(context) ⇒ Object



18
19
20
21
# File 'lib/dashboards/dsl/table.rb', line 18

def render(context)
  data = @data.is_a?(Proc) ? context.instance_exec(&@data) : @data
  render_table(data)
end