Sha256: 4ba8662dd742e5fff1141faa93158d2c70b73a8452e5be183305808d24895419
Contents?: true
Size: 1.3 KB
Versions: 9
Compression:
Stored size: 1.3 KB
Contents
# frozen_string_literal: true module Decidim module Conferences module Admin # A class used to find the ConferenceSpeakers's by the search. class ConferenceSpeakers < Rectify::Query # Syntactic sugar to initialize the class and return the queried objects. # # conference_speakers - the initial ConferenceSpeaker relation that needs to be filtered. # query - query to filter user group names def self.for(conference_speakers, query = nil) new(conference_speakers, query).query end # Initializes the class. # # conference_speakers - the ConferenceSpeaker relation that need to be filtered # query - query to filter user group names def initialize(conference_speakers, query = nil) @conference_speakers = conference_speakers @query = query end # List the conference speakers by the different filters. def query @conference_speakers = filter_by_search(@conference_speakers) @conference_speakers end private def filter_by_search(conference_speakers) return conference_speakers if @query.blank? conference_speakers.where("LOWER(full_name) LIKE LOWER(?)", "%#{@query}%") end end end end end
Version data entries
9 entries across 9 versions & 1 rubygems