Sha256: 3b25b9c326bd916ecdfb6dbdf56966000800c7df81ed61156c0859090cf19579

Contents?: true

Size: 728 Bytes

Versions: 2

Compression:

Stored size: 728 Bytes

Contents

require 'subj_models/concerns/comprising_external_id'

module SubjModels

  module NomenclatureReview

    def self.included(including_class)

      including_class.class_eval do

        include SubjModels::ComprisingExternalId

        after_create :notify

        belongs_to :nomenclature
        belongs_to :user

        validates :user, :nomenclature, :content, presence: true

        scope :nomenclature_id, -> nomenclature { where(nomenclature_id: nomenclature) }

        scope :approved, -> { where(review_approved: true) }

        scope :without_approves, -> { where(review_approved: false) }

      end

    end

    private

    def notify
      NomenclatureReviewMailer.notify(self).deliver
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
subj_models-0.4.1 lib/subj_models/nomenclature_review.rb
subj_models-0.4 lib/subj_models/nomenclature_review.rb