Module: Windy::Finders
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
71
72
73
74
75
76
77
78
|
# File 'lib/windy.rb', line 71
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
63
64
65
|
# File 'lib/windy.rb', line 63
def [](index)
to_a[index]
end
|
#respond_to?(method) ⇒ Boolean
67
68
69
|
# File 'lib/windy.rb', line 67
def respond_to?(method)
method.to_s[/^find(_all)?_by_./] || super
end
|