class Chewie::Query::TermLevel
Attributes
attribute[R]
clause[R]
options[R]
query[R]
strategy[R]
value[R]
Public Class Methods
new(handler, filters)
click to toggle source
# File lib/chewie/query/term_level.rb, line 8 def initialize(handler, filters) @attribute = handler[:attribute] @query = handler[:query] @clause = handler[:clause] @value = filters[attribute] || filters[:query] @options = handler.fetch(:options, {}) @strategy = clause.present? ? 'clause' : 'attribute' end
Public Instance Methods
build()
click to toggle source
# File lib/chewie/query/term_level.rb, line 17 def build return {} if value.nil? return [] if [value].flatten.empty? send("create_with_#{strategy}") end
Private Instance Methods
create_with_attribute()
click to toggle source
# File lib/chewie/query/term_level.rb, line 28 def create_with_attribute context(attribute) do if value_is_not_a_hash { value: value }.merge(options) else value.merge(options) end end end
create_with_clause()
click to toggle source
# File lib/chewie/query/term_level.rb, line 38 def create_with_clause context(query) do { attribute => { value: value }.merge(options) } end end
value_is_not_a_hash()
click to toggle source
# File lib/chewie/query/term_level.rb, line 44 def value_is_not_a_hash !value.is_a? Hash end