Class: Codat::Models::ReportItem

Inherits:
BaseModel show all
Defined in:
lib/codat/models/report_item.rb

Overview

A report item can be present in BalanceSheetReport or ProfitAndLossReport.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

attributes, #format_url, format_url, get, #get, post, #post, successful_response?

Constructor Details

#initialize(json: {}) ⇒ ReportItem

Returns a new instance of ReportItem.



13
14
15
16
17
18
19
# File 'lib/codat/models/report_item.rb', line 13

def initialize(json: {})
  super

  # The items can have an array of items inside. It's weird, but this happens a lot.
  items_json = json.fetch(:items, [])
  @items = items_json.map { |item| ReportItem.new(json: item) }
end

Instance Attribute Details

#itemsObject

Returns the value of attribute items.



11
12
13
# File 'lib/codat/models/report_item.rb', line 11

def items
  @items
end