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:



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

def initialize
  yield(self)
end

Instance Attribute Details

#data_blockObject

Returns the value of attribute data_block.



7
8
9
# File 'lib/datagrid/columns/column.rb', line 7

def data_block
  @data_block
end

#html_blockObject

Returns the value of attribute html_block.



7
8
9
# File 'lib/datagrid/columns/column.rb', line 7

def html_block
  @html_block
end

Instance Method Details

#call_dataObject



21
22
23
# File 'lib/datagrid/columns/column.rb', line 21

def call_data
  data_block.call
end

#call_html(context) ⇒ Object



29
30
31
# File 'lib/datagrid/columns/column.rb', line 29

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

#data(&block) ⇒ Object



13
14
15
# File 'lib/datagrid/columns/column.rb', line 13

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

#html(&block) ⇒ Object



17
18
19
# File 'lib/datagrid/columns/column.rb', line 17

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

#to_sObject



25
26
27
# File 'lib/datagrid/columns/column.rb', line 25

def to_s
  call_data.to_s
end