Class: CustomAttributes::SearchQueryField
- Inherits:
-
Object
- Object
- CustomAttributes::SearchQueryField
- Defined in:
- lib/custom_attributes/search_query_field.rb
Instance Attribute Summary collapse
-
#fuzziness ⇒ Object
readonly
Returns the value of attribute fuzziness.
-
#operator ⇒ Object
readonly
Returns the value of attribute operator.
-
#query ⇒ Object
readonly
Returns the value of attribute query.
Instance Method Summary collapse
- #defaults ⇒ Object
- #field ⇒ Object
-
#initialize(field, defaults) ⇒ SearchQueryField
constructor
A new instance of SearchQueryField.
- #to_query_hash ⇒ Object
Constructor Details
#initialize(field, defaults) ⇒ SearchQueryField
Returns a new instance of SearchQueryField.
5 6 7 8 |
# File 'lib/custom_attributes/search_query_field.rb', line 5 def initialize(field, defaults) @defaults = defaults @field = field end |
Instance Attribute Details
#fuzziness ⇒ Object (readonly)
Returns the value of attribute fuzziness.
3 4 5 |
# File 'lib/custom_attributes/search_query_field.rb', line 3 def fuzziness @fuzziness end |
#operator ⇒ Object (readonly)
Returns the value of attribute operator.
3 4 5 |
# File 'lib/custom_attributes/search_query_field.rb', line 3 def operator @operator end |
#query ⇒ Object (readonly)
Returns the value of attribute query.
3 4 5 |
# File 'lib/custom_attributes/search_query_field.rb', line 3 def query @query end |
Instance Method Details
#defaults ⇒ Object
38 39 40 |
# File 'lib/custom_attributes/search_query_field.rb', line 38 def defaults @defaults ||= { query: '*' } end |
#field ⇒ Object
34 35 36 |
# File 'lib/custom_attributes/search_query_field.rb', line 34 def field @field ||= {} end |
#to_query_hash ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/custom_attributes/search_query_field.rb', line 10 def to_query_hash query_hash = {} return query_hash if query == '*' query_hash = query_hash.merge({query: query}) unless query.nil? query_hash = query_hash.merge({fuzziness: fuzziness}) unless fuzziness.nil? || fuzziness.zero? query_hash = query_hash.merge({operator: operator}) unless operator.nil? query_hash end |