Class: BillerBotResource::Invoice
- Inherits:
-
Resource
- Object
- ActiveResource::Base
- Resource
- BillerBotResource::Invoice
show all
- Defined in:
- lib/biller_bot_resource/invoice.rb
Defined Under Namespace
Classes: Status
Instance Method Summary
collapse
Methods inherited from Resource
#cache_key, config, configure, #initialize, instantiate_collection, query_string
Instance Method Details
#line_items ⇒ Object
15
16
17
18
|
# File 'lib/biller_bot_resource/invoice.rb', line 15
def line_items
@attributes[:line_items] ||= []
@attributes[:line_items]
end
|
#locations ⇒ Object
10
11
12
13
|
# File 'lib/biller_bot_resource/invoice.rb', line 10
def locations
@attributes[:locations] ||= []
@attributes[:locations]
end
|
#save(*args) ⇒ Object
20
21
22
23
24
25
26
|
# File 'lib/biller_bot_resource/invoice.rb', line 20
def save(*args)
line_items = Array.wrap(@attributes.delete(:line_items)).compact
locations = Array.wrap(@attributes.delete(:locations)).compact
@attributes[:line_items_attributes] = line_items unless line_items.empty?
@attributes[:locations_attributes] = locations unless locations.empty?
super
end
|
#total_charge ⇒ Object
28
29
30
|
# File 'lib/biller_bot_resource/invoice.rb', line 28
def total_charge
line_items.map(&:total_charge).inject(:+) || 0
end
|