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.



389
390
391
392
393
394
395
396
397
398
# File 'frontend/app/helpers/search_helper.rb', line 389

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?



426
427
428
429
430
# File 'frontend/app/helpers/search_helper.rb', line 426

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

#fieldObject



401
402
403
# File 'frontend/app/helpers/search_helper.rb', line 401

def field
  @field
end

#labelObject



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

def label
  @label
end

#sort_byObject



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

def sort_by
  @sort_by
end

#sortable?Boolean

Returns:

  • (Boolean)


416
417
418
# File 'frontend/app/helpers/search_helper.rb', line 416

def sortable?
  @sortable
end

#value_for(record) ⇒ Object



406
407
408
# File 'frontend/app/helpers/search_helper.rb', line 406

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