Sha256: 46d9cf455a1b6e6a9cf5a853751fc3ba335f7ff253ae9ae852ad2c93b54de705

Contents?: true

Size: 682 Bytes

Versions: 1

Compression:

Stored size: 682 Bytes

Contents

module Unidom::Accession::Concerns::AsPostFulfiller

  extend ActiveSupport::Concern

  self.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

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
unidom-accession-1.3 app/models/unidom/accession/concerns/as_post_fulfiller.rb