Class: Sourcing::Person

Inherits:
Base
  • Object
show all
Defined in:
lib/sourcing/person.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.find(values, options = {}) ⇒ Object Also known as: []



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/sourcing/person.rb', line 5

def self.find(values, options = {})
  unless values.is_a?(Hash)
    values = {:id => values}
  end

  options = options.dup
  params  = options.delete(:params) || {}

  if email = values[:email]
    self.new(get(uri(:email, email), params, options))

  elsif twitter = values[:twitter]
    self.new(get(uri(:twitter, twitter), params, options))

  elsif github = values[:github]
    self.new(get(uri(:github, github), params, options))

  elsif name = values[:name]
    self.new(get(uri(:name, URI.escape(name)), params, options))

  elsif id = values[:id]
    self.new(get(id, params, options))

  else
    raise ArgumentError, 'Invalid values'
  end

rescue Nestful::ResourceNotFound
end

.search(filters, params = {}) ⇒ Object



35
36
37
# File 'lib/sourcing/person.rb', line 35

def self.search(filters, params = {})
  post :search, params.merge(filters: filters)
end

Instance Method Details

#create_note!(body) ⇒ Object



51
52
53
# File 'lib/sourcing/person.rb', line 51

def create_note!(body)
  post :notes, body: body
end

#favorite!Object



55
56
57
# File 'lib/sourcing/person.rb', line 55

def favorite!
  post :favorite
end

#notesObject



47
48
49
# File 'lib/sourcing/person.rb', line 47

def notes
  get :notes
end

#tweetsObject



43
44
45
# File 'lib/sourcing/person.rb', line 43

def tweets
  get :tweets
end

#unfavorite!Object



59
60
61
# File 'lib/sourcing/person.rb', line 59

def unfavorite!
  delete :favorite
end