Sha256: 5f07fc0ba409d60e8755b5690f0ba99ddb12196a6c5bd5013832f81ddff3cb59

Contents?: true

Size: 864 Bytes

Versions: 1

Compression:

Stored size: 864 Bytes

Contents

# Post Reporting Structure 是岗位汇报结构。

class Unidom::Position::PostReportingStructure < ActiveRecord::Base

  self.table_name = 'unidom_post_reporting_structures'

  include Unidom::Common::Concerns::ModelExtension

  belongs_to :superior_post, class_name: 'Unidom::Position::Post', foreign_key: :superior_post_id
  belongs_to :inferior_post, class_name: 'Unidom::Position::Post', foreign_key: :inferior_post_id

  scope :superior_post_is, ->(superior_post) { where superior_post_id: to_id(superior_post) }
  scope :inferior_post_is, ->(inferior_post) { where inferior_post_id: to_id(inferior_post) }

  def self.report!(superior_post, inferior_post, opened_at = Time.now, elemental = true)
    self.inferior_post_is(inferior_post).superior_post_is(superior_post).valid_at.alive.first_or_create! opened_at: opened_at, elemental: elemental
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
unidom-position-0.2 app/models/unidom/position/post_reporting_structure.rb