Class: Pipekit::Deal

Inherits:
Object
  • Object
show all
Includes:
Repository
Defined in:
lib/pipekit/deal.rb

Instance Method Summary collapse

Methods included from Repository

#all, #create, #find_by, #initialize, #update, #where

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Pipekit::Repository

Instance Method Details

#get_by_person_id(person_id, person_repo: Person.new) ⇒ Object

Raises:



5
6
7
8
# File 'lib/pipekit/deal.rb', line 5

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

#update_by_person(email, params, person_repo: Person.new) ⇒ Object

Finds a person by their email, then finds the first deal related to that person and updates it with the params provided



12
13
14
15
16
# File 'lib/pipekit/deal.rb', line 12

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