Sha256: d902c17b61b9089cb0e185d58e636d1906d6b01e4d8387e5c54ccda5305deaa6

Contents?: true

Size: 1.36 KB

Versions: 24

Compression:

Stored size: 1.36 KB

Contents

module Hobo

  module Scopes

    def self.included_in_class(klass)
      klass.class_eval do
        extend ClassMethods
        metaclass.alias_method_chain :valid_keys_for_has_many_association,   :scopes
        metaclass.alias_method_chain :valid_keys_for_has_one_association,    :scopes
        metaclass.alias_method_chain :valid_keys_for_belongs_to_association, :scopes
      end
    end

    module ClassMethods

      include AutomaticScopes

      include ApplyScopes

      # --- monkey-patches to allow :scope key on has_many, has_one and belongs_to ---
      
      def valid_keys_for_has_many_association_with_scopes
        valid_keys_for_has_many_association_without_scopes + [:scope]
      end

      def valid_keys_for_has_one_association_with_scopes
        valid_keys_for_has_one_association_without_scopes + [:scope]
      end

      def valid_keys_for_belongs_to_association_with_scopes
        valid_keys_for_belongs_to_association_without_scopes + [:scope]
      end

    end

  end

end

ActiveRecord::Associations::AssociationProxy.send(:include, Hobo::Scopes::AssociationProxyExtensions)
ActiveRecord::Associations::AssociationCollection.send(:include, Hobo::Scopes::AssociationCollectionExtensions)
ActiveRecord::Associations::HasManyThroughAssociation.send(:include, Hobo::Scopes::HasManyThroughAssociationExtensions)
require "hobo/scopes/named_scope_extensions"

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
hobo-1.1.0 lib/hobo/scopes.rb
hobo-1.0.3 lib/hobo/scopes.rb
hobo-1.1.0.pre4 lib/hobo/scopes.rb
hobo-1.1.0.pre3 lib/hobo/scopes.rb
hobo-1.1.0.pre2 lib/hobo/scopes.rb
hobo-1.1.0.pre0 lib/hobo/scopes.rb
hobo-1.0.2 lib/hobo/scopes.rb
hobo-1.0.1 lib/hobo/scopes.rb
hobo-1.0.0 lib/hobo/scopes.rb
hobo-0.9.106 lib/hobo/scopes.rb
hobo-0.9.105 lib/hobo/scopes.rb
hobo-0.9.104 lib/hobo/scopes.rb
hobo-0.9.103 lib/hobo/scopes.rb
hobo-0.9.102 lib/hobo/scopes.rb
hobo-0.9.101 lib/hobo/scopes.rb
hobo-0.9.100 lib/hobo/scopes.rb
hobo-0.9.0 lib/hobo/scopes.rb
hobo-0.8.10 lib/hobo/scopes.rb
hobo-0.8.9 lib/hobo/scopes.rb
hobo-0.8.8 lib/hobo/scopes.rb