app/models/unidom/accession/concerns/as_post_fulfiller.rb in unidom-accession-2.0 vs app/models/unidom/accession/concerns/as_post_fulfiller.rb in unidom-accession-2.1
- old
+ new
@@ -5,19 +5,19 @@
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'
- #def fulfill_post!(post: nil, opened_at: Time.now)
- # raise ArgumentError.new('The argument "post" is required.') if post.blank?
- # raise ArgumentError.new('The argument "opened_at" is required.') if opened_at.blank?
- # post_fulfillments.create! fulfilled: post, opened_at: opened_at
- #end
-
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
+
+ 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
end
end