Module: Dillo::Finders
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
84
85
86
87
88
89
90
91
|
# File 'lib/dillo.rb', line 84
def method_missing(method, *args, &block)
if attribute = method.to_s[/^(find(_all)?)_by_(.+)$/, 3]
value = args.first
send($1) { |record| record.send(attribute) == value }
else
super
end
end
|
Instance Method Details
#[](index) ⇒ Object
76
77
78
|
# File 'lib/dillo.rb', line 76
def [](index)
to_a[index]
end
|
#respond_to?(method) ⇒ Boolean
80
81
82
|
# File 'lib/dillo.rb', line 80
def respond_to?(method)
method.to_s[/^find(_all)?_by_./] || super
end
|