Module: Validatious::Addresses::Searchable::ClassMethods
- Defined in:
- lib/validatious/addresses/searchable.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
38
39
40
41
42
43
44
|
# File 'lib/validatious/addresses/searchable.rb', line 38
def method_missing(method, *args, &block)
m = method.to_s.match(/^(find_all)_by_(.+)$/i)
m ||= method.to_s.match(/^(find)_by_(.+)$/i)
return super unless m && args.length == 1
send(m.captures.first.to_sym, args.first, m.captures.last.to_sym)
end
|
Class Method Details
.extended(object) ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/validatious/addresses/searchable.rb', line 10
def self.extended(object)
object.class_eval{
@attributes = []
@aliases = []
@list = []
}
class << object
attr_accessor :attributes, :aliases, :list
end
end
|
Instance Method Details
#find(term, field = :name) ⇒ Object
27
28
29
|
# File 'lib/validatious/addresses/searchable.rb', line 27
def find(term, field=:name)
search(:find, term, field)
end
|
#find_all(term, field = :name) ⇒ Object
31
32
33
|
# File 'lib/validatious/addresses/searchable.rb', line 31
def find_all(term, field=:name)
search(:find_all, term, field)
end
|
#searchable_config {|_self| ... } ⇒ Object
22
23
24
25
|
# File 'lib/validatious/addresses/searchable.rb', line 22
def searchable_config(&block)
yield self
end
|