Sha256: d31f168e95c79c20a52139500a8f992d81d725f078ba3f81a77a8ca3f29875a2

Contents?: true

Size: 1.18 KB

Versions: 1

Compression:

Stored size: 1.18 KB

Contents

class Unico::RegulatoryAct < Unico::Model
  extend EnumerateIt

  self.abstract_class = true
  self.table_name = :unico_regulatory_acts

  has_enumeration_for :classification, with: RegulatoryActClassification,
                                       create_helpers: { prefix: true }
  has_enumeration_for :regulatory_act_type, create_helpers: { prefix: true },
                                            create_scopes: true

  belongs_to :parent, class_name: '::RegulatoryAct'

  has_and_belongs_to_many :dissemination_sources, join_table: :unico_dissemination_sources_unico_regulatory_acts

  has_many :children, class_name: '::RegulatoryAct', foreign_key: :parent_id, dependent: :restrict_with_exception

  validates :regulatory_act_type, :creation_date, :publication_date, :content,
            :signature_date, :vigor_date, :act_number, :classification, presence: true

  with_options allow_blank: true do |allowing_blank|
    allowing_blank.validates :article_number, length: { maximum: 6 }
    allowing_blank.validates :article_description, length: { maximum: 512 }
    allowing_blank.validates :act_number, :content, uniqueness: true
    allowing_blank.validates :act_number, numericality: true
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
unico-training-7.8.0 app/models/unico/regulatory_act.rb