Class: ActiveAdmin::Views::TableFor::Column
- Inherits:
 - 
      Object
      
        
- Object
 - ActiveAdmin::Views::TableFor::Column
 
 
- Defined in:
 - lib/active_admin/views/components/table_for.rb
 
Instance Attribute Summary collapse
- 
  
    
      #data  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Returns the value of attribute data.
 - 
  
    
      #html_class  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Returns the value of attribute html_class.
 - 
  
    
      #title  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    
Returns the value of attribute title.
 
Instance Method Summary collapse
- 
  
    
      #initialize(*args, &block)  ⇒ Column 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of Column.
 - #pretty_title ⇒ Object
 - 
  
    
      #sort_key  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Returns the key to be used for sorting this column.
 - #sortable? ⇒ Boolean
 
Constructor Details
#initialize(*args, &block) ⇒ Column
Returns a new instance of Column.
      144 145 146 147 148 149 150 151 152 153 154 155 156 157 158  | 
    
      # File 'lib/active_admin/views/components/table_for.rb', line 144 def initialize(*args, &block) @options = args. @title = args[0] html_classes = [:col] if @options.has_key?(:class) html_classes << @options.delete(:class) elsif @title.present? html_classes << "col-#{@title.to_s.parameterize(separator: "_")}" end @html_class = html_classes.join(" ") @data = args[1] || args[0] @data = block if block @resource_class = args[2] end  | 
  
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
      142 143 144  | 
    
      # File 'lib/active_admin/views/components/table_for.rb', line 142 def data @data end  | 
  
#html_class ⇒ Object
Returns the value of attribute html_class.
      142 143 144  | 
    
      # File 'lib/active_admin/views/components/table_for.rb', line 142 def html_class @html_class end  | 
  
#title ⇒ Object
Returns the value of attribute title.
      142 143 144  | 
    
      # File 'lib/active_admin/views/components/table_for.rb', line 142 def title @title end  | 
  
Instance Method Details
#pretty_title ⇒ Object
      190 191 192 193 194 195 196 197 198 199 200 201  | 
    
      # File 'lib/active_admin/views/components/table_for.rb', line 190 def pretty_title if @title.is_a? Symbol default = @title.to_s.titleize if @options[:i18n].respond_to? :human_attribute_name @title = @options[:i18n].human_attribute_name @title, default: default else default end else @title end end  | 
  
#sort_key ⇒ Object
Returns the key to be used for sorting this column
Defaults to the column’s method if its a symbol
column :username
# => Sort key will be set to 'username'
You can set the sort key by passing a string or symbol to the sortable option:
column :username, sortable: 'other_column_to_sort_on'
  
      181 182 183 184 185 186 187 188  | 
    
      # File 'lib/active_admin/views/components/table_for.rb', line 181 def sort_key # If boolean or nil, use the default sort key. if @options[:sortable].nil? || @options[:sortable] == true || @options[:sortable] == false sort_column_name else @options[:sortable].to_s end end  | 
  
#sortable? ⇒ Boolean
      160 161 162 163 164 165 166 167 168  | 
    
      # File 'lib/active_admin/views/components/table_for.rb', line 160 def sortable? if @options.has_key?(:sortable) !!@options[:sortable] elsif @resource_class @resource_class.column_names.include?(sort_column_name) else @title.present? end end  |