Skip to content

Commit

Permalink
Remove memoization from remaining resource attribute setters
Browse files Browse the repository at this point in the history
This fixes an issue where updates to some attributes resulting from an
API call would not appear on the object passed to that API call. It also
makes the setters have a more regular behavior.
  • Loading branch information
mvz committed Aug 17, 2021
1 parent ad8d2e1 commit d7348c7
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 21 deletions.
6 changes: 3 additions & 3 deletions lib/moneybird/resource/contact.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ class Contact
)

def notes=(notes)
@notes ||= notes.map{ |note| Moneybird::Resource::Generic::Note.build(note) }
@notes = notes.map{ |note| Moneybird::Resource::Generic::Note.build(note) }
end

def events=(events)
@events ||= events.map{ |event| Moneybird::Resource::Generic::Event.build(event) }
@events = events.map{ |event| Moneybird::Resource::Generic::Event.build(event) }
end

def custom_fields=(custom_fields)
@custom_fields ||= custom_fields.map { |custom_field| Moneybird::Resource::CustomField.build(custom_field) }
@custom_fields = custom_fields.map { |custom_field| Moneybird::Resource::CustomField.build(custom_field) }
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions lib/moneybird/resource/documents/purchase_invoice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class PurchaseInvoice
)

def notes=(notes)
@notes ||= notes.map{ |note| Moneybird::Resource::Generic::Note.build(note) }
@notes = notes.map{ |note| Moneybird::Resource::Generic::Note.build(note) }
end

def contact=(attributes)
Expand All @@ -47,11 +47,11 @@ def details=(line_items)
end

def events=(events)
@events ||= events.map{ |event| Moneybird::Resource::Generic::Event.build(event) }
@events = events.map{ |event| Moneybird::Resource::Generic::Event.build(event) }
end

def payments=(payments)
@payments ||= payments.map{ |payment| Moneybird::Resource::Invoice::Payment.build(payment) }
@payments = payments.map{ |payment| Moneybird::Resource::Invoice::Payment.build(payment) }
end
end
end
6 changes: 3 additions & 3 deletions lib/moneybird/resource/documents/receipt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Receipt
)

def notes=(notes)
@notes ||= notes.map{ |note| Moneybird::Resource::Generic::Note.build(note) }
@notes = notes.map{ |note| Moneybird::Resource::Generic::Note.build(note) }
end

def contact=(attributes)
Expand All @@ -47,11 +47,11 @@ def details=(line_items)
end

def events=(events)
@events ||= events.map{ |event| Moneybird::Resource::Generic::Event.build(event) }
@events = events.map{ |event| Moneybird::Resource::Generic::Event.build(event) }
end

def payments=(payments)
@payments ||= payments.map{ |payment| Moneybird::Resource::Invoice::Payment.build(payment) }
@payments = payments.map{ |payment| Moneybird::Resource::Invoice::Payment.build(payment) }
end
end
end
8 changes: 4 additions & 4 deletions lib/moneybird/resource/estimate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ class Estimate
)

def notes=(notes)
@notes ||= notes.map{ |note| Moneybird::Resource::Generic::Note.build(note) }
@notes = notes.map{ |note| Moneybird::Resource::Generic::Note.build(note) }
end

def contact=(attributes)
@contact ||= Moneybird::Resource::Contact.build(attributes)
@contact = Moneybird::Resource::Contact.build(attributes)
end

def details=(line_items)
@details ||= line_items.map{ |line_item| Moneybird::Resource::Invoice::Details.build(line_item) }
@details = line_items.map{ |line_item| Moneybird::Resource::Invoice::Details.build(line_item) }
end
end
end
end
4 changes: 2 additions & 2 deletions lib/moneybird/resource/external_sales_invoice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class ExternalSalesInvoice
)

def notes=(notes)
@notes ||= notes.map{ |note| Moneybird::Resource::Generic::Note.build(note) }
@notes = notes.map{ |note| Moneybird::Resource::Generic::Note.build(note) }
end

def contact=(attributes)
Expand All @@ -55,7 +55,7 @@ def details=(line_items)
end

def events=(events)
@events ||= events.map{ |event| Moneybird::Resource::Generic::Event.build(event) }
@events = events.map{ |event| Moneybird::Resource::Generic::Event.build(event) }
end
end
end
2 changes: 1 addition & 1 deletion lib/moneybird/resource/identity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ class Identity
end

def custom_fields=(custom_fields)
@custom_fields ||= custom_fields.map { |custom_field| Moneybird::Resource::CustomField.build(custom_field) }
@custom_fields = custom_fields.map { |custom_field| Moneybird::Resource::CustomField.build(custom_field) }
end
end
4 changes: 2 additions & 2 deletions lib/moneybird/resource/recurring_sales_invoice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class RecurringSalesInvoice
)

def notes=(notes)
@notes ||= notes.map{ |note| Moneybird::Resource::Generic::Note.build(note) }
@notes = notes.map{ |note| Moneybird::Resource::Generic::Note.build(note) }
end

def contact=(attributes)
Expand All @@ -52,7 +52,7 @@ def details=(line_items)
end

def events=(events)
@events ||= events.map{ |event| Moneybird::Resource::Generic::Event.build(event) }
@events = events.map{ |event| Moneybird::Resource::Generic::Event.build(event) }
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions lib/moneybird/resource/sales_invoice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class SalesInvoice
)

def notes=(notes)
@notes ||= notes.map{ |note| Moneybird::Resource::Generic::Note.build(note) }
@notes = notes.map{ |note| Moneybird::Resource::Generic::Note.build(note) }
end

def contact=(attributes)
Expand All @@ -82,11 +82,11 @@ def details=(line_items)
end

def events=(events)
@events ||= events.map{ |event| Moneybird::Resource::Generic::Event.build(event) }
@events = events.map{ |event| Moneybird::Resource::Generic::Event.build(event) }
end

def custom_fields=(custom_fields)
@custom_fields ||= custom_fields.map { |custom_field| Moneybird::Resource::CustomField.build(custom_field) }
@custom_fields = custom_fields.map { |custom_field| Moneybird::Resource::CustomField.build(custom_field) }
end
end
end

0 comments on commit d7348c7

Please sign in to comment.