Class: Datagrid::Columns::Column::ResponseFormat

Inherits:
Object
  • Object
show all
Defined in:
lib/datagrid/columns/column.rb

Overview

Datagrid class holding an information of how a column should be rendered in data/console/csv format and HTML format

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ ResponseFormat

Returns a new instance of ResponseFormat.

Yields:

  • (_self)

Yield Parameters:



11
12
13
# File 'lib/datagrid/columns/column.rb', line 11

def initialize
  yield(self)
end

Instance Attribute Details

#data_blockObject

Returns the value of attribute data_block.



9
10
11
# File 'lib/datagrid/columns/column.rb', line 9

def data_block
  @data_block
end

#html_blockObject

Returns the value of attribute html_block.



9
10
11
# File 'lib/datagrid/columns/column.rb', line 9

def html_block
  @html_block
end

Instance Method Details

#call_dataObject



23
24
25
# File 'lib/datagrid/columns/column.rb', line 23

def call_data
  data_block.call
end

#call_html(context) ⇒ Object



31
32
33
# File 'lib/datagrid/columns/column.rb', line 31

def call_html(context)
  context.instance_eval(&html_block)
end

#data(&block) ⇒ Object



15
16
17
# File 'lib/datagrid/columns/column.rb', line 15

def data(&block)
  self.data_block = block
end

#html(&block) ⇒ Object



19
20
21
# File 'lib/datagrid/columns/column.rb', line 19

def html(&block)
  self.html_block = block
end

#to_sObject



27
28
29
# File 'lib/datagrid/columns/column.rb', line 27

def to_s
  call_data.to_s
end