aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/dynamic_scope_match.rb
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2012-05-02 23:57:52 +0100
committerJon Leighton <j@jonathanleighton.com>2012-05-04 12:50:03 +0100
commit0c76a52c472546083a199f685f96170031b36fdd (patch)
tree6a2ef0077eb6d2904a420456db0025fc7639327c /activerecord/lib/active_record/dynamic_scope_match.rb
parent5f62c86b50f21ef14ffda1112a8cd002e87590ca (diff)
downloadrails-0c76a52c472546083a199f685f96170031b36fdd.tar.gz
rails-0c76a52c472546083a199f685f96170031b36fdd.tar.bz2
rails-0c76a52c472546083a199f685f96170031b36fdd.zip
clean up implementation of dynamic methods. use method compilation etc.
Diffstat (limited to 'activerecord/lib/active_record/dynamic_scope_match.rb')
-rw-r--r--activerecord/lib/active_record/dynamic_scope_match.rb30
1 files changed, 0 insertions, 30 deletions
diff --git a/activerecord/lib/active_record/dynamic_scope_match.rb b/activerecord/lib/active_record/dynamic_scope_match.rb
deleted file mode 100644
index 6c043d29c4..0000000000
--- a/activerecord/lib/active_record/dynamic_scope_match.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-module ActiveRecord
-
- # = Active Record Dynamic Scope Match
- #
- # Provides dynamic attribute-based scopes such as <tt>scoped_by_price(4.99)</tt>
- # if, for example, the <tt>Product</tt> has an attribute with that name. You can
- # chain more <tt>scoped_by_* </tt> methods after the other. It acts like a named
- # scope except that it's dynamic.
- class DynamicScopeMatch
- METHOD_PATTERN = /^scoped_by_([_a-zA-Z]\w*)$/
-
- def self.match(method)
- if method.to_s =~ METHOD_PATTERN
- new(true, $1 && $1.split('_and_'))
- end
- end
-
- def initialize(scope, attribute_names)
- @scope = scope
- @attribute_names = attribute_names
- end
-
- attr_reader :scope, :attribute_names
- alias :scope? :scope
-
- def valid_arguments?(arguments)
- arguments.size >= @attribute_names.size
- end
- end
-end