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.



382
383
384
385
386
387
388
389
390
391
# File 'frontend/app/helpers/search_helper.rb', line 382

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

let’s rename this method?



419
420
421
422
423
# File 'frontend/app/helpers/search_helper.rb', line 419

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

#fieldObject



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

def field
  @field
end

#labelObject



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

def label
  @label
end

#sort_byObject



414
415
416
# File 'frontend/app/helpers/search_helper.rb', line 414

def sort_by
  @sort_by
end

#sortable?Boolean

Returns:

  • (Boolean)


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

def sortable?
  @sortable
end

#value_for(record) ⇒ Object



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

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