Class: Etapper::JournalEntry
- Inherits:
-
EtapAbstract
- Object
- EtapAbstract
- Etapper::JournalEntry
- Defined in:
- lib/etapper/classes/journal_entry.rb
Constant Summary collapse
- TYPES =
{ :note => 1, :contact => 2, :gift => 5, :pledge => 6, :payment => 7, :recurring_gift_schedule => 8, :recurring_gift => 9, :segmented_donation => 10, :soft_credit => 11, :disbursement => 12, :segmented_pledge => 13 }
Instance Attribute Summary collapse
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
- .find(query) ⇒ Object
-
.findByAccount(account, options = {}) ⇒ Object
Retrieves a collection of gifts using getJournalEntries given an account.
-
.getter ⇒ Object
Returns the “get” method of the class as a symbol (e.g. :getGift).
-
.symbolize ⇒ Object
Returns the name of the class as a symbol (e.g. :gift).
-
.type ⇒ Object
Returns the type number of the particular subclass (e.g. 5).
Instance Method Summary collapse
-
#account ⇒ Object
Associates the account that this gift belongs to.
-
#account=(val) ⇒ Object
Sets the account that this gift belongs to.
- #definedValues ⇒ Object
-
#initialize(base = nil) ⇒ JournalEntry
constructor
Set the ‘type’ field based on the real class name, if it wasn’t already.
Methods inherited from EtapAbstract
#==, #base, cname, etap_read_only, #method_missing, #new?, #save
Constructor Details
#initialize(base = nil) ⇒ JournalEntry
Set the ‘type’ field based on the real class name, if it wasn’t already
25 26 27 28 29 |
# File 'lib/etapper/classes/journal_entry.rb', line 25 def initialize(base = nil) super @type = self.class.symbolize @base.type ||= TYPES[@type] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Etapper::EtapAbstract
Instance Attribute Details
#type ⇒ Object (readonly)
Returns the value of attribute type.
21 22 23 |
# File 'lib/etapper/classes/journal_entry.rb', line 21 def type @type end |
Class Method Details
.find(query) ⇒ Object
62 63 64 65 66 67 68 69 70 71 |
# File 'lib/etapper/classes/journal_entry.rb', line 62 def self.find(query) case query when /\d+\.\d+\.\d+/ # "4310.0.2276679" g = client.send(getter, query) new(g) if g when Hash a = Account.find(query[:account]) findByAccount(a) end end |
.findByAccount(account, options = {}) ⇒ Object
Retrieves a collection of gifts using getJournalEntries given an account
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/etapper/classes/journal_entry.rb', line 74 def self.findByAccount(account, ={}) p = Etapper::API::PagedJournalEntriesRequest.new(true, # clearCache 100, # count 0, # start account.ref, nil, # baseQuery [:endDate], [:startDate], [type]) j = Etapper.client.getJournalEntries(p) if j.count > 0 j.data.collect {|je| new(je)} else nil end end |
.getter ⇒ Object
Returns the “get” method of the class as a symbol (e.g. :getGift)
58 59 60 |
# File 'lib/etapper/classes/journal_entry.rb', line 58 def self.getter "get#{cname}".to_sym end |
.symbolize ⇒ Object
Returns the name of the class as a symbol (e.g. :gift)
48 49 50 |
# File 'lib/etapper/classes/journal_entry.rb', line 48 def self.symbolize cname.symbolize end |
.type ⇒ Object
Returns the type number of the particular subclass (e.g. 5)
53 54 55 |
# File 'lib/etapper/classes/journal_entry.rb', line 53 def self.type TYPES[self.symbolize] end |
Instance Method Details
#account ⇒ Object
Associates the account that this gift belongs to.
37 38 39 |
# File 'lib/etapper/classes/journal_entry.rb', line 37 def account @account ||= Account.find(accountRef) end |
#account=(val) ⇒ Object
Sets the account that this gift belongs to.
42 43 44 45 |
# File 'lib/etapper/classes/journal_entry.rb', line 42 def account=(val) @account = val @base.accountRef = val.ref end |
#definedValues ⇒ Object
31 32 33 34 |
# File 'lib/etapper/classes/journal_entry.rb', line 31 def definedValues @base.definedValues ||= Etapper::API::ArrayOfDefinedValue.new @definedValues ||= Etapper::DefinedValueHash.new(base.definedValues) end |