Module: Isurvey::Collector
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
4
5
6
7
8
9
10
11
|
# File 'lib/isurvey/collector.rb', line 4
def method_missing(method, *args, &block)
if method.to_s =~ /^find_by_(.+)$/
to_find = method.to_s.sub(/find_by_/, '')
all.select { |obj| obj.send(to_find.to_sym) == args.first }
else
super
end
end
|
Instance Method Details
#[](ind) ⇒ Object
21
22
23
|
# File 'lib/isurvey/collector.rb', line 21
def [](ind)
all[ind]
end
|
#all ⇒ Object
13
14
15
|
# File 'lib/isurvey/collector.rb', line 13
def all
ObjectSpace.each_object(self).entries
end
|
#first ⇒ Object
17
18
19
|
# File 'lib/isurvey/collector.rb', line 17
def first
all.first
end
|