class ActiveAdmin::Views::TableFor::Column

def default_options

def default_options
  {
    :sortable => true
  }
end

def initialize(*args, &block)

def initialize(*args, &block)
  @options = default_options.merge(args.last.is_a?(::Hash) ? args.pop : {})
  @title = pretty_title args[0]
  @data  = args[1] || args[0]
  @data = block if block
end

def pretty_title(raw)

def pretty_title(raw)
  if raw.is_a?(Symbol)
    if @options[:i18n] && @options[:i18n].respond_to?(:human_attribute_name) && human_name = @options[:i18n].human_attribute_name(raw)
      raw = human_name
    end
    raw.to_s.titleize
  else
    raw
  end
end

def sort_key


# => Sort key will be 'login'
column('Username', :sortable => 'login'){ @user.pretty_name }

sort the column on:
will not be sortable unless you pass a string to sortable to
If you pass a block to be rendered for this column, the column

column :username, :sortable => 'other_column_to_sort_on'
to the sortable option:
You can set the sort key by passing a string or symbol

# => Sort key will be set to 'username'
column :username
Defaults to the column's method if its a symbol

Returns the key to be used for sorting this column
def sort_key
  if @options[:sortable] == true || @options[:sortable] == false
    @data.to_s
  else
    @options[:sortable].to_s
  end
end

def sortable?

def sortable?
  if @data.is_a?(Proc)
    [String, Symbol].include?(@options[:sortable].class)
  else
    @options[:sortable]
  end
end