Class: Mio::Search
- Inherits:
-
Object
show all
- Defined in:
- lib/mio/search.rb
Instance Method Summary
collapse
Constructor Details
#initialize(client) ⇒ Search
Returns a new instance of Search.
3
4
5
|
# File 'lib/mio/search.rb', line 3
def initialize client
@client = client
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_sym, *arguments, &block) ⇒ Object
11
12
13
14
15
16
17
18
|
# File 'lib/mio/search.rb', line 11
def method_missing method_sym, *arguments, &block
if method_sym.to_s =~ /^find_(.*)_by_(.*)$/
all($1, $2, arguments.first)
else
super
end
end
|
Instance Method Details
#all(resource, key, value) ⇒ Object
7
8
9
|
# File 'lib/mio/search.rb', line 7
def all resource, key, value
@client.find_all(resource)[resource].select{|o| o[key] == value}
end
|
#respond_to?(method_sym, include_private = false) ⇒ Boolean
20
21
22
23
24
25
26
|
# File 'lib/mio/search.rb', line 20
def respond_to? method_sym, include_private=false
if method_sym.to_s =~ /^find_(.*)_by_(.*)$/
true
else
super
end
end
|