Sha256: 9e79e2a1f9b405012cbf05c7d721263f474d1e61d2da48c7abe8ee192c272a9b

Contents?: true

Size: 697 Bytes

Versions: 7

Compression:

Stored size: 697 Bytes

Contents

# frozen_string_literal: true

module Ibrain
  module UserMethods
    extend ActiveSupport::Concern

    include Ibrain::UserApiAuthentication
    include Ibrain::UserReporting

    included do
      extend Ibrain::DisplayMoney
      after_create :auto_generate_ibrain_api_key

      include Ibrain::RansackableAttributes unless included_modules.include?(Ibrain::RansackableAttributes)
    end

    def auto_generate_ibrain_api_key
      return if !respond_to?(:ibrain_api_key) || ibrain_api_key.present?

      if Ibrain::Config.generate_api_key_for_all_roles || (ibrain_roles.map(&:name) & Ibrain::Config.roles_for_auto_api_key).any?
        generate_ibrain_api_key!
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ibrain-core-0.1.6 app/models/ibrain/concerns/user_methods.rb
ibrain-core-0.1.5 app/models/ibrain/concerns/user_methods.rb
ibrain-core-0.1.4 app/models/ibrain/concerns/user_methods.rb
ibrain-core-0.1.3 app/models/ibrain/concerns/user_methods.rb
ibrain-core-0.1.2 app/models/ibrain/concerns/user_methods.rb
ibrain-core-0.1.1 app/models/ibrain/concerns/user_methods.rb
ibrain-core-0.1.0 app/models/ibrain/concerns/user_methods.rb