Sha256: fc2c4b49871be54f012efbce3f4f07d823231898ca0dd37ededff2ea0fdd5a21

Contents?: true

Size: 1.22 KB

Versions: 17

Compression:

Stored size: 1.22 KB

Contents

# frozen_string_literal: true

module Authlogic
  module ActsAsAuthentic
    # Magic columns are like ActiveRecord's created_at and updated_at columns.
    # They are "magically" maintained for you. Authlogic has the same thing, but
    # these are maintained on the session side. Please see "Magic Columns" in
    # `Session::Base` for more details. This module merely adds validations for
    # the magic columns if they exist.
    module MagicColumns
      def self.included(klass)
        klass.class_eval do
          add_acts_as_authentic_module(Methods)
        end
      end

      # Methods relating to the magic columns
      module Methods
        def self.included(klass)
          klass.class_eval do
            if column_names.include?("login_count")
              validates_numericality_of :login_count,
                only_integer: true,
                greater_than_or_equal_to: 0,
                allow_nil: true
            end
            if column_names.include?("failed_login_count")
              validates_numericality_of :failed_login_count,
                only_integer: true,
                greater_than_or_equal_to: 0,
                allow_nil: true
            end
          end
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
authlogic-6.4.3 lib/authlogic/acts_as_authentic/magic_columns.rb
authlogic-nicho-6.6 lib/authlogic/acts_as_authentic/magic_columns.rb
authlogic-nicho-6.5 lib/authlogic/acts_as_authentic/magic_columns.rb
authlogic-6.4.2 lib/authlogic/acts_as_authentic/magic_columns.rb
authlogic-6.4.1 lib/authlogic/acts_as_authentic/magic_columns.rb
authlogic-6.4.0 lib/authlogic/acts_as_authentic/magic_columns.rb
authlogic-6.3.0 lib/authlogic/acts_as_authentic/magic_columns.rb
authlogic-6.2.0 lib/authlogic/acts_as_authentic/magic_columns.rb
authlogic-5.2.0 lib/authlogic/acts_as_authentic/magic_columns.rb
authlogic-6.1.0 lib/authlogic/acts_as_authentic/magic_columns.rb
authlogic-6.0.0 lib/authlogic/acts_as_authentic/magic_columns.rb
authlogic-5.1.0 lib/authlogic/acts_as_authentic/magic_columns.rb
authlogic-5.0.4 lib/authlogic/acts_as_authentic/magic_columns.rb
authlogic-5.0.3 lib/authlogic/acts_as_authentic/magic_columns.rb
authlogic-5.0.2 lib/authlogic/acts_as_authentic/magic_columns.rb
authlogic-5.0.1 lib/authlogic/acts_as_authentic/magic_columns.rb
authlogic-5.0.0 lib/authlogic/acts_as_authentic/magic_columns.rb