Sha256: 9b552f7d059d8cde9b04e65e0cb03f359997d1a00fa62d54bb7ed7afae99674a

Contents?: true

Size: 777 Bytes

Versions: 14

Compression:

Stored size: 777 Bytes

Contents

module Notee
  class ApplicationRecord < ActiveRecord::Base
    self.abstract_class = true

    # scopes
    scope :trash, -> { where(is_deleted: true) }
    scope :not_trash, -> { where(is_deleted: false) }
    scope :time_limit, -> { where('updated_at <= ?', Time.current - 60*60*24*30) }

    # authority check
    before_create :create_authority
    before_update :update_authority, unless: :is_destroy?
    before_update :destroy_authority, if: :is_destroy?

    def create_authority
      Authority.check('create', self)
    end

    def update_authority
      Authority.check('update', self)
    end

    def destroy_authority
      Authority.check('destroy', self)
    end

    def is_destroy?
      return true if self.is_deleted == true
      false
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
notee-1.1.2.2 app/models/notee/application_record.rb
notee-1.1.2.1 app/models/notee/application_record.rb
notee-1.1.2 app/models/notee/application_record.rb
notee-1.1.1 app/models/notee/application_record.rb
notee-1.1.0 app/models/notee/application_record.rb
notee-1.0.8 app/models/notee/application_record.rb
notee-1.0.7 app/models/notee/application_record.rb
notee-1.0.6 app/models/notee/application_record.rb
notee-1.0.5 app/models/notee/application_record.rb
notee-1.0.4 app/models/notee/application_record.rb
notee-1.0.3 app/models/notee/application_record.rb
notee-1.0.2 app/models/notee/application_record.rb
notee-1.0.1 app/models/notee/application_record.rb
notee-1.0.0 app/models/notee/application_record.rb