Sha256: e7fc8d7517dd09a6668c780d055965207e9516b162a4f45157deedc4c74b56c9

Contents?: true

Size: 687 Bytes

Versions: 4

Compression:

Stored size: 687 Bytes

Contents

module Pipekit
  class Deal
    include Repository

    def get_by_person_id(person_id, person_repo: Person.new)
      raise UnknownPersonError, "No person ID supplied when getting deals by person ID" unless person_id
      person_repo.find_deals(person_id)
    end

    # Finds a person by their email, then finds the first deal related to that
    # person and updates it with the params provided
    def update_by_person(email, params, person_repo: Person.new)
      person = person_repo.find_by(email: email)
      deal = get_by_person_id(person[:id], person_repo: person_repo).first
      update(deal[:id], params)
    end
  end

  UnknownPersonError = Class.new(StandardError)
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pipekit-1.2.0 lib/pipekit/deal.rb
pipekit-1.0.2 lib/pipekit/deal.rb
pipekit-1.0.1 lib/pipekit/deal.rb
pipekit-1.0.0 lib/pipekit/deal.rb