lib/collector/repository.rb in collector-0.0.14 vs lib/collector/repository.rb in collector-0.0.15

- old
+ new

@@ -57,31 +57,39 @@ collection.find(attributes).map do |document| deserialize!(document) end end + def find_first_by(attributes) + find_by(attributes).first + end + def all find_by end def find_by_id(id) find_by(_id: id) end def find_first_by_id(id) - find_by_id(id).first + find_first_by(_id: id) end def method_missing(method_sym, *arguments, &block) if method_sym.to_s =~ /^find_by_(.*)$/ find_by($1.to_sym => arguments.first) + elsif method_sym.to_s =~ /^find_first_by_(.*)$/ + find_first_by($1.to_sym => arguments.first) else super end end def respond_to?(method_sym, include_private = false) if method_sym.to_s =~ /^find_by_(.*)$/ + true + elsif method_sym.to_s =~ /^find_first_by_(.*)$/ true else super end end