Sha256: 442c3e5a276c867a05dd4a6f4f24514d8743f0908173cd2eb181e94a0454e81a

Contents?: true

Size: 1.35 KB

Versions: 1

Compression:

Stored size: 1.35 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
    #raise ArgumentError.new('Argument fulfilled is required.') if fulfilled.blank?
    raise ArgumentError.new('Argument fulfiller is required.') if fulfiller.blank?
    raise ArgumentError.new('Argument opened_at is required.') if opened_at.blank?
    self.create! fulfiller: fulfiller, fulfilled: fulfilled, opened_at: opened_at
  end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
unidom-accession-2.3.1 app/models/unidom/accession/post_fulfillment.rb