18F/micropurchase

View on GitHub
app/models/rules_factory.rb

Summary

Maintainability
A
0 mins
Test Coverage
class RulesFactory
  def initialize(auction)
    @auction = auction
    @eligibility = EligibilityFactory.new(@auction).create
  end

  def create
    if type == 'sealed_bid'
      Rules::SealedBidAuction.new(auction, eligibility)
    elsif type == 'reverse'
      Rules::ReverseAuction.new(auction, eligibility)
    end
  end

  private

  attr_reader :auction
  attr_reader :eligibility

  def type
    auction.type
  end
end