class Admino::Query::SearchField
Attributes
config[R]
params[R]
Public Class Methods
new(config, params)
click to toggle source
# File lib/admino/query/search_field.rb, line 11 def initialize(config, params) @config = config @params = ActiveSupport::HashWithIndifferentAccess.new(params) end
Public Instance Methods
augment_scope(scope)
click to toggle source
# File lib/admino/query/search_field.rb, line 16 def augment_scope(scope) if present? scope.send(scope_name, value) else scope end end
param_name()
click to toggle source
# File lib/admino/query/search_field.rb, line 43 def param_name config.name end
present?()
click to toggle source
# File lib/admino/query/search_field.rb, line 39 def present? value.present? end
scope_name()
click to toggle source
# File lib/admino/query/search_field.rb, line 47 def scope_name config.name end
value()
click to toggle source
# File lib/admino/query/search_field.rb, line 24 def value value = params.fetch(:query, {}).fetch(param_name, nil) if config.coerce_to value = begin coercer = Coercible::Coercer.new coercer[value.class].send(config.coerce_to, value) rescue Coercible::UnsupportedCoercion nil end end value || config.default_value end