Sha256: 72194d5a9b5d2350e4705185a343f201f37b90d763b0f766e48ad63518e38192
Contents?: true
Size: 913 Bytes
Versions: 2
Compression:
Stored size: 913 Bytes
Contents
module Unidom::Accession::Concerns::AsPostFulfiller extend ActiveSupport::Concern 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, 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
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
unidom-accession-2.2 | app/models/unidom/accession/concerns/as_post_fulfiller.rb |
unidom-accession-2.1 | app/models/unidom/accession/concerns/as_post_fulfiller.rb |