Class: Symphonia::QueryColumns::AttributeColumn
- Inherits:
-
GenericColumn
- Object
- GenericColumn
- Symphonia::QueryColumns::AttributeColumn
- Defined in:
- lib/symphonia/query_columns/attribute_column.rb
Instance Attribute Summary collapse
-
#attribute ⇒ Object
readonly
Returns the value of attribute attribute.
-
#header ⇒ Object
writeonly
Sets the attribute header.
-
#no_header ⇒ Object
Returns the value of attribute no_header.
-
#sort ⇒ Object
writeonly
Sets the attribute sort.
-
#sort_options ⇒ Object
Returns the value of attribute sort_options.
Attributes inherited from GenericColumn
#default, #header, #includes, #joins, #model, #name, #preload, #query, #sort, #sort_definition
Instance Method Summary collapse
-
#format_value(view, entity) ⇒ Object
def header(table_header_tag) if @header === false table_header_tag.th(@name, ”, sort: false) else table_header_tag.th(@name, title, @sort.nil?, sort_options: (sort_options || {).merge(sort_column_name)}) end end.
-
#initialize(attribute, query, options = {}) ⇒ AttributeColumn
constructor
A new instance of AttributeColumn.
- #reference? ⇒ Boolean
Methods inherited from GenericColumn
#css_classes, #default?, #header?, #inspect, #sort?, #sum, #sum_value, #summarize?, #title, #value
Constructor Details
#initialize(attribute, query, options = {}) ⇒ AttributeColumn
Returns a new instance of AttributeColumn.
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/symphonia/query_columns/attribute_column.rb', line 11 def initialize(attribute, query, ={}) @attribute = attribute @name = attribute.name @query = query @model = query.model @options = @includes = .delete(:includes) || reference? && [@name] || [] @preload = .delete(:preload) || reference? && [@name] || [] @joins = Array(.delete(:joins)) || [] @sort_definition = attribute.sort_column @sort = attribute.sort? end |
Instance Attribute Details
#attribute ⇒ Object (readonly)
Returns the value of attribute attribute.
5 6 7 |
# File 'lib/symphonia/query_columns/attribute_column.rb', line 5 def attribute @attribute end |
#header=(value) ⇒ Object (writeonly)
Sets the attribute header
7 8 9 |
# File 'lib/symphonia/query_columns/attribute_column.rb', line 7 def header=(value) @header = value end |
#no_header ⇒ Object
Returns the value of attribute no_header.
6 7 8 |
# File 'lib/symphonia/query_columns/attribute_column.rb', line 6 def no_header @no_header end |
#sort=(value) ⇒ Object (writeonly)
Sets the attribute sort
7 8 9 |
# File 'lib/symphonia/query_columns/attribute_column.rb', line 7 def sort=(value) @sort = value end |
#sort_options ⇒ Object
Returns the value of attribute sort_options.
6 7 8 |
# File 'lib/symphonia/query_columns/attribute_column.rb', line 6 def @sort_options end |
Instance Method Details
#format_value(view, entity) ⇒ Object
def header(table_header_tag)
if @header === false
table_header_tag.th(@name, '', sort: false)
else
table_header_tag.th(@name, title, {sort: @sort.nil?, sort_options: ( || {}).merge({column: sort_column_name})})
end
end
37 38 39 |
# File 'lib/symphonia/query_columns/attribute_column.rb', line 37 def format_value(view, entity) @attribute.format(view, entity) end |
#reference? ⇒ Boolean
25 26 27 |
# File 'lib/symphonia/query_columns/attribute_column.rb', line 25 def reference? @attribute.is_a?(Symphonia::ModelAttributes::ReferenceAttribute) end |