Class: QueryFilter

Inherits:
Object
  • Object
show all
Includes:
Redmine::I18n
Defined in:
app/models/query.rb

Instance Method Summary collapse

Methods included from Redmine::I18n

#current_language, #day_letter, #day_name, #find_language, #format_date, #format_hours, #format_time, included, #l, #l_hours, #l_hours_short, #l_or_humanize, #languages_options, #ll, #lu, #month_name, #set_language_if_valid, #valid_languages

Constructor Details

#initialize(field, options) ⇒ QueryFilter

Returns a new instance of QueryFilter.


187
188
189
190
191
192
193
# File 'app/models/query.rb', line 187

def initialize(field, options)
  @field = field.to_s
  @options = options
  @options[:name] ||= l(options[:label] || "field_#{field}".gsub(/_id$/, ''))
  # Consider filters with a Proc for values as remote by default
  @remote = options.key?(:remote) ? options[:remote] : options[:values].is_a?(Proc)
end

Instance Method Details

#[](arg) ⇒ Object


195
196
197
198
199
200
201
# File 'app/models/query.rb', line 195

def [](arg)
  if arg == :values
    values
  else
    @options[arg]
  end
end

#remoteObject


213
214
215
# File 'app/models/query.rb', line 213

def remote
  @remote
end

#valuesObject


203
204
205
206
207
208
209
210
211
# File 'app/models/query.rb', line 203

def values
  @values ||= begin
    values = @options[:values]
    if values.is_a?(Proc)
      values = values.call
    end
    values
  end
end