Class: Kiva::JournalEntry
- Inherits:
-
Object
- Object
- Kiva::JournalEntry
- Defined in:
- lib/kiva.rb
Overview
Journal entries are attached to loans. Using the class method load
you can retrieve all entries attached to a particular loan.
Constant Summary collapse
- KEY =
"journal_entries"
- LOAD =
"http://api.kivaws.org/v1/loans/%s/journal_entries.json?"
Instance Attribute Summary collapse
-
#author ⇒ Object
Returns the value of attribute author.
-
#body ⇒ Object
Returns the value of attribute body.
-
#bulk ⇒ Object
Returns the value of attribute bulk.
-
#comment_count ⇒ Object
Returns the value of attribute comment_count.
-
#date ⇒ Object
Returns the value of attribute date.
-
#id ⇒ Object
Returns the value of attribute id.
-
#recommendation_count ⇒ Object
attr_accessor :image.
-
#subject ⇒ Object
Returns the value of attribute subject.
Class Method Summary collapse
-
.load(id, page = nil, include_bulk = nil) ⇒ Object
Load journal entries for a loan.
Instance Method Summary collapse
-
#comments ⇒ Object
Retrieve an array of
Comment
instances associated with this entry.
Instance Attribute Details
#author ⇒ Object
Returns the value of attribute author.
390 391 392 |
# File 'lib/kiva.rb', line 390 def @author end |
#body ⇒ Object
Returns the value of attribute body.
387 388 389 |
# File 'lib/kiva.rb', line 387 def body @body end |
#bulk ⇒ Object
Returns the value of attribute bulk.
392 393 394 |
# File 'lib/kiva.rb', line 392 def bulk @bulk end |
#comment_count ⇒ Object
Returns the value of attribute comment_count.
389 390 391 |
# File 'lib/kiva.rb', line 389 def comment_count @comment_count end |
#date ⇒ Object
Returns the value of attribute date.
388 389 390 |
# File 'lib/kiva.rb', line 388 def date @date end |
#id ⇒ Object
Returns the value of attribute id.
386 387 388 |
# File 'lib/kiva.rb', line 386 def id @id end |
#recommendation_count ⇒ Object
attr_accessor :image
394 395 396 |
# File 'lib/kiva.rb', line 394 def recommendation_count @recommendation_count end |
#subject ⇒ Object
Returns the value of attribute subject.
391 392 393 |
# File 'lib/kiva.rb', line 391 def subject @subject end |
Class Method Details
.load(id, page = nil, include_bulk = nil) ⇒ Object
Load journal entries for a loan.
Parameters
id
: a loan id or an instance of Loan
Returns
an array of JournalEntry
instances.
Corresponds
developers.wiki.kiva.org/KivaAPI#loans/ltidgt/journalentries
428 429 430 431 432 433 434 435 436 437 438 439 |
# File 'lib/kiva.rb', line 428 def load id, page = nil, include_bulk = nil id = id.id if id.is_a? Loan url = LOAD % id url = page ? url + "page=#{page}&" : url url = (! include_bulk.nil?) ? url + "include_bulk=#{include_bulk}" : url raw = raw = Kiva.execute(url) unw = JSON.parse(raw) Kiva._populate JournalEntry, unw[KEY] end |
Instance Method Details
#comments ⇒ Object
Retrieve an array of Comment
instances associated with this entry. N.B. this leads to a further network call.
400 401 402 403 404 405 406 407 408 409 410 |
# File 'lib/kiva.rb', line 400 def comments unless @comments return nil if id.is_nil? if @comment_count != 0 @comments = Comment.load(this) else @commetns = [] end end @comments end |