app/models/unidom/accession/concerns/as_post_fulfiller.rb in unidom-accession-2.3 vs app/models/unidom/accession/concerns/as_post_fulfiller.rb in unidom-accession-2.3.1
- old
+ new
@@ -8,15 +8,25 @@
included do |includer|
has_many :post_fulfillments, class_name: 'Unidom::Accession::PostFulfillment', as: :fulfiller
has_many :fulfilled_posts, through: :post_fulfillments, source: :fulfilled, source_type: 'Unidom::Position::Post'
+ ##
+ # 让当前参与者在指定时间 at 开始履行岗位 post 。指定时间缺省为当前时间。如:
+ # selected_person.fulfill_post! post
+ # 或者
+ # selected_person.fulfill_post! post, at: Time.now-1.day
def fulfill_post!(post, at: Time.now)
raise ArgumentError.new('The post argument is required.') if post.blank?
raise ArgumentError.new('The at argument is required.' ) if at.blank?
post_fulfillments.create! fulfilled: post, opened_at: at
end
+ ##
+ # 判断当前参与者在指定时间 at 是否被履行制定的岗位 post 。指定时间缺省为当前时间。如:
+ # post.fulfill_post? post
+ # 或者
+ # post.fulfill_post? post, at: Time.now
def fulfill_post?(post, at: Time.now)
raise ArgumentError.new('The post argument is required.') if post.blank?
raise ArgumentError.new('The at argument is required.' ) if at.blank?
post_fulfillments.fulfilled_is(post).valid_at(now: at).exists?
end