lib/sequel/model.rb in sequel-0.0.15 vs lib/sequel/model.rb in sequel-0.0.16
- old
+ new
@@ -200,23 +200,26 @@
model.dataset.filter(primary_key => @pkey).delete
end
FIND_BY_REGEXP = /^find_by_(.*)/.freeze
FILTER_BY_REGEXP = /^filter_by_(.*)/.freeze
+ ALL_BY_REGEXP = /^all_by_(.*)/.freeze
def self.method_missing(m, *args)
Thread.exclusive do
method_name = m.to_s
if method_name =~ FIND_BY_REGEXP
c = $1
meta_def(method_name) {|arg| find(c => arg)}
- send(m, *args) if respond_to?(m)
elsif method_name =~ FILTER_BY_REGEXP
c = $1
meta_def(method_name) {|arg| filter(c => arg)}
- send(m, *args) if respond_to?(m)
+ elsif method_name =~ ALL_BY_REGEXP
+ c = $1
+ meta_def(method_name) {|arg| filter(c => arg).all}
end
end
+ respond_to?(m) ? send(m, *args) : super(m, *args)
end
def db; self.class.db; end
def reload