Class: Getto::Params::Search::Query

Inherits:
Object
  • Object
show all
Defined in:
lib/getto/params/search.rb

Defined Under Namespace

Classes: Checker

Instance Method Summary collapse

Constructor Details

#initialize(query:) ⇒ Query

Returns a new instance of Query.



91
92
93
# File 'lib/getto/params/search.rb', line 91

def initialize(query:)
  @query = query
end

Instance Method Details

#to_h {|Checker.new(spec)| ... } ⇒ Object

Yields:



95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/getto/params/search.rb', line 95

def to_h
  spec = {}
  yield Checker.new(spec)

  spec.map{|key,checker|
    if search = @query[key]
      if checker.call(search)
        [key.to_sym, search]
      end
    end
  }.compact.to_h
end