Class: Search

Inherits:
Object
  • Object
show all
Defined in:
app/models/search.rb

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Search

Returns a new instance of Search.



2
3
4
# File 'app/models/search.rb', line 2

def initialize(params={})
  @params = Hash.new.merge(params['search'] || {})
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_sym, *args) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'app/models/search.rb', line 6

def method_missing(method_sym,*args)
  case method_sym.to_s
  when /^\[\]=?$/
    @params.send(method_sym,*args)
  when /^(.*)=$/
    @params.update($1,*args)
  else
    @params[method_sym.to_s]
  end
end