Sha256: 7cf6c61045a5d510606b216882149c27cce3960d3d1609ed595912517be78d2a

Contents?: true

Size: 717 Bytes

Versions: 229

Compression:

Stored size: 717 Bytes

Contents

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
    def self.match(method)
      return unless method.to_s =~ /^scoped_by_([_a-zA-Z]\w*)$/
      new(true, $1 && $1.split('_and_'))
    end

    def initialize(scope, attribute_names)
      @scope           = scope
      @attribute_names = attribute_names
    end

    attr_reader :scope, :attribute_names
    alias :scope? :scope
  end
end

Version data entries

229 entries across 198 versions & 16 rubygems

Version Path
activerecord-3.2.16 lib/active_record/dynamic_scope_match.rb
activerecord-3.2.15 lib/active_record/dynamic_scope_match.rb
activerecord-3.2.15.rc3 lib/active_record/dynamic_scope_match.rb
activerecord-3.2.15.rc2 lib/active_record/dynamic_scope_match.rb
activerecord-3.2.15.rc1 lib/active_record/dynamic_scope_match.rb
activerecord-3.2.14 lib/active_record/dynamic_scope_match.rb
activerecord-3.2.14.rc2 lib/active_record/dynamic_scope_match.rb
activerecord-3.2.14.rc1 lib/active_record/dynamic_scope_match.rb
swipe-rails-0.0.5 vendor/bundle/gems/activerecord-3.2.13/lib/active_record/dynamic_scope_match.rb
active_mailer-0.0.9 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/dynamic_scope_match.rb
active_mailer-0.0.8 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/dynamic_scope_match.rb
active_mailer-0.0.7 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/dynamic_scope_match.rb
active_mailer-0.0.6 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/dynamic_scope_match.rb
challah-1.0.0.beta3 vendor/bundle/gems/activerecord-3.2.13/lib/active_record/dynamic_scope_match.rb
fc-webicons-0.0.4 vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/dynamic_scope_match.rb
challah-1.0.0.beta2 vendor/bundle/gems/activerecord-3.2.13/lib/active_record/dynamic_scope_match.rb
challah-1.0.0.beta vendor/bundle/gems/activerecord-3.2.13/lib/active_record/dynamic_scope_match.rb
challah-1.0.0.beta vendor/bundle/gems/activerecord-3.2.11/lib/active_record/dynamic_scope_match.rb
fc-webicons-0.0.3 vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/dynamic_scope_match.rb
fc-webicons-0.0.2 vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.13/lib/active_record/dynamic_scope_match.rb