Sha256: d9f5728201212b7ca72dba4b2b0d470df00a49e871ab524bb960ed5df3c1b949

Contents?: true

Size: 602 Bytes

Versions: 4

Compression:

Stored size: 602 Bytes

Contents

require 'i_am_i_can/subject/role_querying'
require 'i_am_i_can/subject/permission_querying'

module IAmICan
  module Subject
    extend ActiveSupport::Concern

    class_methods do
    end

    included do
      define_model_callbacks :role_assign, :cancel_role_assign, :role_update

      Object.const_set (role_assoc_class = reflections[__roles].options[:join_table].camelize),
                       Class.new(ActiveRecord::Base)
      has_many :"assoc_with_#{__roles}", -> { where('expire_at IS NULL OR expire_at > ?', Time.current) },
               class_name: role_assoc_class
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
i_am_i_can-4.3.3 lib/i_am_i_can/subject.rb
i_am_i_can-4.3.2 lib/i_am_i_can/subject.rb
i_am_i_can-4.3.1 lib/i_am_i_can/subject.rb
i_am_i_can-4.3.0 lib/i_am_i_can/subject.rb