Class: TheCity::Donation
Instance Attribute Summary
Attributes inherited from ApiObject
#error_messages, #marked_for_destruction
Class Method Summary collapse
-
.load_donation_by_id(pledge_id) ⇒ Object
Loads the donation by the specified ID.
Instance Method Summary collapse
-
#amount_cents ⇒ Object
Convert amount to cents.
-
#initialize(reader = nil) ⇒ Donation
constructor
Constructor.
Methods inherited from ApiObject
__tc_attributes, #delete, #initialize_from_json_object, #is_deleted?, #save, #set_attributes, tc_attr_accessor, #to_attributes
Constructor Details
#initialize(reader = nil) ⇒ Donation
Constructor.
51 52 53 54 55 56 57 |
# File 'lib/api/donation.rb', line 51 def initialize(reader = nil) if reader.is_a?(DonationReader) initialize_from_json_object(reader.load_feed) elsif reader.is_a?(Hash) initialize_from_json_object(reader) end end |
Class Method Details
.load_donation_by_id(pledge_id) ⇒ Object
Loads the donation by the specified ID.
Returns a new TheCity::Donation object.
41 42 43 44 |
# File 'lib/api/donation.rb', line 41 def self.load_donation_by_id(pledge_id) donation_reader = DonationReader.new(Pledge_id) self.new(donation_reader) end |
Instance Method Details
#amount_cents ⇒ Object
Convert amount to cents.
62 63 64 |
# File 'lib/api/donation.rb', line 62 def amount_cents (self.amount.to_f * 100).round.to_i end |