Class: SearchHelper::SearchColumn

Inherits:
Object
  • Object
show all
Defined in:
frontend/app/helpers/search_helper.rb

Instance Method Summary collapse

Constructor Details

#initialize(label, value_block, opts, search_data) ⇒ SearchColumn

Returns a new instance of SearchColumn.



372
373
374
375
376
377
378
379
380
381
# File 'frontend/app/helpers/search_helper.rb', line 372

def initialize(label, value_block, opts, search_data)
  @field = opts[:field]
  @label = label
  @value_block = value_block
  @classes = "col "
  @classes << opts[:class] if opts[:class]
  @sortable = opts[:sortable] || false
  @sort_by = opts[:sort_by] || ""
  @search_data = search_data
end

Instance Method Details

#classObject



409
410
411
412
413
# File 'frontend/app/helpers/search_helper.rb', line 409

def class
  @classes << " sortable" if sortable?
  @classes << " sort-#{@search_data.current_sort_direction}" if sortable? && @search_data.sorted_by === @sort_by
  @classes
end

#fieldObject



384
385
386
# File 'frontend/app/helpers/search_helper.rb', line 384

def field
  @field
end

#labelObject



394
395
396
# File 'frontend/app/helpers/search_helper.rb', line 394

def label
  @label
end

#sort_byObject



404
405
406
# File 'frontend/app/helpers/search_helper.rb', line 404

def sort_by
  @sort_by
end

#sortable?Boolean

Returns:

  • (Boolean)


399
400
401
# File 'frontend/app/helpers/search_helper.rb', line 399

def sortable?
  @sortable
end

#value_for(record) ⇒ Object



389
390
391
# File 'frontend/app/helpers/search_helper.rb', line 389

def value_for(record)
  @value_block.call(record)
end