Sha256: c6d2bf6ff17a91575f2349c34a5b28c7967908394e84c2ecaccdb06efb865a39

Contents?: true

Size: 982 Bytes

Versions: 10

Compression:

Stored size: 982 Bytes

Contents

module DeviseInvitable
  module Inviter
    extend ActiveSupport::Concern

    included do
      extend ClassMethods
      attr_writer :invitation_limit unless respond_to? :invitation_limit
    end

    def invitation_limit
      self[:invitation_limit] || self.class.invitation_limit
    end

    # Return true if this user has invitations left to send
    def has_invitations_left?
      if self.class.invitation_limit.present?
        if invitation_limit
          return invitation_limit > 0
        else
          return self.class.invitation_limit > 0
        end
      else
        return true
      end
    end

    protected

      def decrement_invitation_limit!
        if self.class.invitation_limit.present?
          self.invitation_limit ||= self.class.invitation_limit
          self.update_attribute(:invitation_limit, invitation_limit - 1)
        end
      end

      module ClassMethods
        Devise::Models.config(self, :invitation_limit)
      end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/devise_invitable-2.0.9/lib/devise_invitable/inviter.rb
devise_invitable-2.0.9 lib/devise_invitable/inviter.rb
devise_invitable-2.0.8 lib/devise_invitable/inviter.rb
devise_invitable-2.0.7 lib/devise_invitable/inviter.rb
devise_invitable-2.0.6 lib/devise_invitable/inviter.rb
devise_invitable-2.0.5 lib/devise_invitable/inviter.rb
devise_invitable-2.0.4 lib/devise_invitable/inviter.rb
devise_invitable-2.0.3 lib/devise_invitable/inviter.rb
devise_invitable-2.0.2 lib/devise_invitable/inviter.rb
devise_invitable-2.0.1 lib/devise_invitable/inviter.rb