-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds the ability to get attributes for Report Cells
Note that this means that Report Cells are no longer core classes (e.g String), but are Report::Cell instances. ReportCell is a SimpleDelegator to the type of the underlying value (usually String from Xero), but this may make strict equality tests fail.
- Loading branch information
Showing
4 changed files
with
185 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
module XeroGateway | ||
class Report | ||
|
||
# Adds #attributes to the cells we're grabbing, since Xero Report Cells use XML like: | ||
# <Cell> | ||
# <Value>Interest Income (270)</Value> | ||
# <Attributes> | ||
# <Attribute> | ||
# <Value>e9482110-7245-4a76-bfe2-14500495a076</Value> | ||
# <Id>account</Id> | ||
# </Attribute> | ||
# </Attributes> | ||
# </Cell> | ||
# | ||
# We delegate to the topmost "<Value>" class and decorate with an "attributes" hash | ||
# for the "attribute: value" pairs | ||
class Cell < SimpleDelegator | ||
attr_reader :attributes, :value | ||
|
||
def initialize(value, new_attributes = {}) | ||
@value = value | ||
@attributes = new_attributes | ||
super(value) | ||
end | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters