Sha256: b1acbf6a2512e5ae4d53c02f0b15add4da8e02182f5cf929fbf1776d648e48a2

Contents?: true

Size: 1.18 KB

Versions: 3

Compression:

Stored size: 1.18 KB

Contents

##
# Post Fulfillment 是岗位履行。

class Unidom::Accession::PostFulfillment < Unidom::Accession::ApplicationRecord

  self.table_name = 'unidom_post_fulfillments'

  include Unidom::Common::Concerns::ModelExtension

  belongs_to :fulfiller, polymorphic: true
  belongs_to :fulfilled, polymorphic: true

  scope :fulfilled_by, ->(fulfiller) { where fulfiller: fulfiller }
  scope :fulfilled_is, ->(fulfilled) { where fulfilled: fulfilled }

  scope :part_time, ->(part_time = true) { where part_time: part_time }
  scope :temporary, ->(temporary = true) { where temporary: temporary }

  ##
  # 将工作岗位 fulfilled 和履行者 fulfiller 在给定的时间 opened_at 关联起来。 opened_at 缺省为当前时间。如:
  # Unidom::Accession::PostFulfillment.fulfill! fulfilled: post, fulfiller: selected_person
  def self.fulfill!(fulfilled: nil, fulfiller: nil, opened_at: Time.now)

    assert_present! :fulfilled, fulfilled
    assert_present! :fulfiller, fulfiller
    assert_present! :opened_at, opened_at

    create! fulfiller: fulfiller, fulfilled: fulfilled, opened_at: opened_at

  end

end unless Unidom::Common::Neglection.namespace_neglected? 'Unidom::Accession::PostFulfillment'

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
unidom-accession-3.0 app/models/unidom/accession/post_fulfillment.rb
unidom-accession-2.3.6 app/models/unidom/accession/post_fulfillment.rb
unidom-accession-2.3.5 app/models/unidom/accession/post_fulfillment.rb