Class: Datagrid::Columns::Column
- Inherits:
-
Object
- Object
- Datagrid::Columns::Column
- Defined in:
- lib/datagrid/columns/column.rb
Defined Under Namespace
Classes: ResponseFormat
Instance Attribute Summary collapse
-
#data_block ⇒ Object
readonly
Returns the value of attribute data_block.
-
#grid_class ⇒ Class
readonly
Grid class where column is defined.
-
#html_block ⇒ Object
readonly
Returns the value of attribute html_block.
-
#name ⇒ Symbol
readonly
Column name.
-
#options ⇒ Hash<Symbol, Object>
readonly
Column options.
-
#query ⇒ Object
readonly
Returns the value of attribute query.
Instance Method Summary collapse
-
#data? ⇒ Boolean
Weather a column should be displayed in data.
-
#data_value(model, grid) ⇒ Object
deprecated
Deprecated.
Use #data_value instead
-
#enabled?(grid) ⇒ Boolean
Weather a column is available via
if
andunless
options. -
#header ⇒ String
Column header.
-
#html? ⇒ Boolean
Weather a column should be displayed in HTML.
-
#html_class ⇒ Object
deprecated
Deprecated.
Use #tag_options instead.
-
#inspect ⇒ String
Column console inspection.
-
#label ⇒ Object
deprecated
Deprecated.
Use #header instead
-
#mandatory? ⇒ Boolean
Weather a column is explicitly marked mandatory.
-
#mandatory_explicitly_set? ⇒ Boolean
Weather a
mandatory
option is explicitly set. -
#order ⇒ Object
Column order expression.
-
#order_by_value? ⇒ Boolean
Weather a column should be ordered by value.
- #order_desc ⇒ Object
-
#preload ⇒ Object
preload
option value. -
#supports_order? ⇒ Boolean
Weather column support order.
-
#tag_options ⇒ Hash<Symbol, Object>
tag_options
option value. -
#to_s ⇒ String
Column header.
Instance Attribute Details
#data_block ⇒ Object (readonly)
Returns the value of attribute data_block.
48 49 50 |
# File 'lib/datagrid/columns/column.rb', line 48 def data_block @data_block end |
#grid_class ⇒ Class (readonly)
Returns grid class where column is defined.
48 49 50 |
# File 'lib/datagrid/columns/column.rb', line 48 def grid_class @grid_class end |
#html_block ⇒ Object (readonly)
Returns the value of attribute html_block.
48 49 50 |
# File 'lib/datagrid/columns/column.rb', line 48 def html_block @html_block end |
#name ⇒ Symbol (readonly)
Returns column name.
48 |
# File 'lib/datagrid/columns/column.rb', line 48 attr_reader :grid_class, :name, :query, :options, :data_block, :html_block |
#options ⇒ Hash<Symbol, Object> (readonly)
Returns column options.
48 |
# File 'lib/datagrid/columns/column.rb', line 48 attr_reader :grid_class, :name, :query, :options, :data_block, :html_block |
#query ⇒ Object (readonly)
Returns the value of attribute query.
48 49 50 |
# File 'lib/datagrid/columns/column.rb', line 48 def query @query end |
Instance Method Details
#data? ⇒ Boolean
Returns weather a column should be displayed in data.
136 137 138 |
# File 'lib/datagrid/columns/column.rb', line 136 def data? data_block != nil end |
#data_value(model, grid) ⇒ Object
Use Datagrid::Columns#data_value instead
76 77 78 79 |
# File 'lib/datagrid/columns/column.rb', line 76 def data_value(model, grid) # backward compatibility method grid.data_value(name, model) end |
#enabled?(grid) ⇒ Boolean
Returns weather a column is available via if
and unless
options.
165 166 167 |
# File 'lib/datagrid/columns/column.rb', line 165 def enabled?(grid) ::Datagrid::Utils.process_availability(grid, [:if], [:unless]) end |
#header ⇒ String
Returns column header.
87 88 89 90 91 92 93 |
# File 'lib/datagrid/columns/column.rb', line 87 def header if (header = [:header]) Datagrid::Utils.callable(header) else Datagrid::Utils.translate_from_namespace(:columns, grid_class, name) end end |
#html? ⇒ Boolean
Returns weather a column should be displayed in HTML.
131 132 133 |
# File 'lib/datagrid/columns/column.rb', line 131 def html? [:html] != false end |
#html_class ⇒ Object
Use #tag_options instead.
151 152 153 154 155 156 |
# File 'lib/datagrid/columns/column.rb', line 151 def html_class Datagrid::Utils.warn_once( "Column#html_class is deprecated. Use Column#tag_options instead.", ) [:class] end |
#inspect ⇒ String
Returns column console inspection.
170 171 172 |
# File 'lib/datagrid/columns/column.rb', line 170 def inspect "#<#{self.class} #{grid_class}##{name} #{.inspect}>" end |
#label ⇒ Object
Use #header instead
82 83 84 |
# File 'lib/datagrid/columns/column.rb', line 82 def label [:label] end |
#mandatory? ⇒ Boolean
Returns weather a column is explicitly marked mandatory.
141 142 143 |
# File 'lib/datagrid/columns/column.rb', line 141 def mandatory? !![:mandatory] end |
#mandatory_explicitly_set? ⇒ Boolean
Returns weather a mandatory
option is explicitly set.
159 160 161 |
# File 'lib/datagrid/columns/column.rb', line 159 def mandatory_explicitly_set? .key?(:mandatory) end |
#order ⇒ Object
Returns column order expression.
96 97 98 99 100 101 102 103 |
# File 'lib/datagrid/columns/column.rb', line 96 def order return nil if [:order] == false if .key?(:order) && [:order] != true [:order] else driver.default_order(grid_class.scope, name) end end |
#order_by_value? ⇒ Boolean
Returns weather a column should be ordered by value.
120 121 122 |
# File 'lib/datagrid/columns/column.rb', line 120 def order_by_value? !![:order_by_value] end |
#order_desc ⇒ Object
124 125 126 127 128 |
# File 'lib/datagrid/columns/column.rb', line 124 def order_desc return nil unless order [:order_desc] end |
#preload ⇒ Object
Returns preload
option value.
207 208 209 210 211 212 213 214 215 |
# File 'lib/datagrid/columns/column.rb', line 207 def preload preload = [:preload] if preload == true && driver.can_preload?(grid_class.scope, name) name else preload end end |
#supports_order? ⇒ Boolean
Returns weather column support order.
106 107 108 |
# File 'lib/datagrid/columns/column.rb', line 106 def supports_order? !!order || order_by_value? end |
#tag_options ⇒ Hash<Symbol, Object>
Returns tag_options
option value.
146 147 148 |
# File 'lib/datagrid/columns/column.rb', line 146 def [:tag_options] || {} end |
#to_s ⇒ String
Returns column header.
175 176 177 |
# File 'lib/datagrid/columns/column.rb', line 175 def to_s header end |