Class: Kiva::Lender
- Inherits:
-
Object
- Object
- Kiva::Lender
- Includes:
- Api, DynamicInitializer
- Defined in:
- lib/ruby-kiva/lender.rb
Instance Attribute Summary collapse
-
#country_code ⇒ Object
Returns the value of attribute country_code.
-
#invitee_count ⇒ Object
Returns the value of attribute invitee_count.
-
#lender_id ⇒ Object
Returns the value of attribute lender_id.
-
#loan_because ⇒ Object
Returns the value of attribute loan_because.
-
#loan_count ⇒ Object
Returns the value of attribute loan_count.
-
#name ⇒ Object
Returns the value of attribute name.
-
#occupation ⇒ Object
Returns the value of attribute occupation.
-
#occupational_info ⇒ Object
Returns the value of attribute occupational_info.
-
#personal_url ⇒ Object
Returns the value of attribute personal_url.
-
#uid ⇒ Object
Returns the value of attribute uid.
-
#whereabouts ⇒ Object
Returns the value of attribute whereabouts.
Class Method Summary collapse
-
.find(params = {}) ⇒ Object
Find Lenders __either__ :id : A single ID or a comma Separated String of IDs or an Array of IDs __or__ :loan_id : A single loan ID __or__ :team_id : a single team ID, supports :sort_by.
- .newest(params = {}) ⇒ Object
Instance Method Summary collapse
- #lender_page_url ⇒ Object
-
#loans(params = {}) ⇒ Object
find the loans for this lender loans are cached to avoid roundtrips, refetch the lender if you need to refresh loans.
- #to_s ⇒ Object
Methods included from DynamicInitializer
Methods included from Api
app_id, app_id=, friendly, friendly=, included
Instance Attribute Details
#country_code ⇒ Object
Returns the value of attribute country_code.
5 6 7 |
# File 'lib/ruby-kiva/lender.rb', line 5 def country_code @country_code end |
#invitee_count ⇒ Object
Returns the value of attribute invitee_count.
5 6 7 |
# File 'lib/ruby-kiva/lender.rb', line 5 def invitee_count @invitee_count end |
#lender_id ⇒ Object
Returns the value of attribute lender_id.
5 6 7 |
# File 'lib/ruby-kiva/lender.rb', line 5 def lender_id @lender_id end |
#loan_because ⇒ Object
Returns the value of attribute loan_because.
5 6 7 |
# File 'lib/ruby-kiva/lender.rb', line 5 def loan_because @loan_because end |
#loan_count ⇒ Object
Returns the value of attribute loan_count.
5 6 7 |
# File 'lib/ruby-kiva/lender.rb', line 5 def loan_count @loan_count end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/ruby-kiva/lender.rb', line 5 def name @name end |
#occupation ⇒ Object
Returns the value of attribute occupation.
5 6 7 |
# File 'lib/ruby-kiva/lender.rb', line 5 def occupation @occupation end |
#occupational_info ⇒ Object
Returns the value of attribute occupational_info.
5 6 7 |
# File 'lib/ruby-kiva/lender.rb', line 5 def occupational_info @occupational_info end |
#personal_url ⇒ Object
Returns the value of attribute personal_url.
5 6 7 |
# File 'lib/ruby-kiva/lender.rb', line 5 def personal_url @personal_url end |
#uid ⇒ Object
Returns the value of attribute uid.
5 6 7 |
# File 'lib/ruby-kiva/lender.rb', line 5 def uid @uid end |
#whereabouts ⇒ Object
Returns the value of attribute whereabouts.
5 6 7 |
# File 'lib/ruby-kiva/lender.rb', line 5 def whereabouts @whereabouts end |
Class Method Details
.find(params = {}) ⇒ Object
Find Lenders __either__ :id : A single ID or a comma Separated String of IDs or an Array of IDs __or__ :loan_id : A single loan ID __or__ :team_id : a single team ID, supports :sort_by
If searching for a single ID, then this method can return nil (no item with this ID found). Otherwise this method will always return a PagedArray instance (which might be empty though) If querying for multiple items, then :page is supported
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/ruby-kiva/lender.rb', line 42 def self.find(params = {}) if params[:id] # find one or many by lender ID data = get("/lenders/#{sanitize_id_parameter(params[:id])}.json", :query => (params)) many = sanitize_id_parameter(params[:id]).include?(',') elsif params[:loan_id] # find lenders for a loan data = get("/loans/#{params[:loan_id]}/lenders.json", :query => (params)) many = true elsif params[:team_id] data = get("/teams/#{params[:team_id]}/lenders.json", :query => (params)) many = true else data = get("/lenders/search.json", :query => (params)) many = true end json_to_paged_array(data, 'lenders', many) end |
.newest(params = {}) ⇒ Object
27 28 29 |
# File 'lib/ruby-kiva/lender.rb', line 27 def self.newest(params = {}) json_to_paged_array(get('/lenders/newest.json', :query => (params)), 'lenders', true) end |
Instance Method Details
#lender_page_url ⇒ Object
13 14 15 |
# File 'lib/ruby-kiva/lender.rb', line 13 def lender_page_url "http://www.kiva.org/lender/#{self.lender_id}" end |
#loans(params = {}) ⇒ Object
find the loans for this lender loans are cached to avoid roundtrips, refetch the lender if you need to refresh loans
19 20 21 |
# File 'lib/ruby-kiva/lender.rb', line 19 def loans(params = {}) @loans ||= Loan.find(params.merge({:lender_id => self.lender_id})) end |
#to_s ⇒ Object
23 24 25 |
# File 'lib/ruby-kiva/lender.rb', line 23 def to_s() "<Lender #{self.lender_id}>" end |