Sha256: 126fb27e0c0aaba7666071cd5b72444d1858d28511b1b46bfcdc1aa82eedc92b

Contents?: true

Size: 1.23 KB

Versions: 16

Compression:

Stored size: 1.23 KB

Contents

module Authlogic
  module Session
    # = Authenticates Many Association
    #
    # An object of this class is used as a proxy for the authenticates_many relationship. It basically allows you to "save" scope details and call them on an object, which allows you to do the following:
    #
    #   @account.user_sessions.new
    #   @account.user_sessions.find
    #   # ... etc
    #
    # You can call all of the class level methods off of an object with a saved scope, so that calling the above methods scopes the user sessions down to that specific account.
    class AuthenticatesManyAssociation # :nodoc:
      attr_accessor :klass, :find_options, :id
      
      def initialize(klass, find_options, id)
        self.klass = klass
        self.find_options = find_options
        self.id = id
      end
      
      [:create, :create!, :find, :new].each do |method|
        class_eval <<-"end_eval", __FILE__, __LINE__
          def #{method}(*args)
            klass.with_scope(scope_options) do
              klass.#{method}(*args)
            end
          end
        end_eval
      end
      alias_method :build, :new
    
      private
        def scope_options
          {:find_options => find_options, :id => id}
        end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
authlogic-1.2.1 lib/authlogic/session/authenticates_many_association.rb
authlogic-1.2.2 lib/authlogic/session/authenticates_many_association.rb
authlogic-1.3.1 lib/authlogic/session/authenticates_many_association.rb
authlogic-1.3.2 lib/authlogic/session/authenticates_many_association.rb
authlogic-1.3.0 lib/authlogic/session/authenticates_many_association.rb
authlogic-1.3.3 lib/authlogic/session/authenticates_many_association.rb
authlogic-1.4.1 lib/authlogic/session/authenticates_many_association.rb
authlogic-1.4.0 lib/authlogic/session/authenticates_many_association.rb
authlogic-1.3.6 lib/authlogic/session/authenticates_many_association.rb
authlogic-1.3.4 lib/authlogic/session/authenticates_many_association.rb
authlogic-1.3.5 lib/authlogic/session/authenticates_many_association.rb
authlogic-1.3.7 lib/authlogic/session/authenticates_many_association.rb
authlogic-1.3.8 lib/authlogic/session/authenticates_many_association.rb
authlogic-1.3.9 lib/authlogic/session/authenticates_many_association.rb
authlogic-1.4.3 lib/authlogic/session/authenticates_many_association.rb
authlogic-1.4.2 lib/authlogic/session/authenticates_many_association.rb