Class: Clickwrap::ReceiptHtml
- Inherits:
-
Object
- Object
- Clickwrap::ReceiptHtml
- Defined in:
- lib/clickwrap/receipt_html.rb
Overview
The human-readable projection of a receipt.
Same facts as the canonical JSON, rendered for someone who has to read them — a reviewer answering a complaint, an operator investigating a dispute, a person asking what they agreed to. Never a different set of facts, and never a stronger claim: where the JSON says a digest detects ordinary modification, the HTML says that too, in a sentence.
It is deliberately plain, self-contained HTML with no framework, no external asset, and no JavaScript, because a receipt frequently ends up saved to disk, attached to an email, or printed, and it has to still make sense there.
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#receipt ⇒ Object
readonly
Returns the value of attribute receipt.
Instance Method Summary collapse
-
#initialize(receipt, view_context: nil, body: nil) ⇒ ReceiptHtml
constructor
A new instance of ReceiptHtml.
- #render ⇒ Object
Constructor Details
#initialize(receipt, view_context: nil, body: nil) ⇒ ReceiptHtml
Returns a new instance of ReceiptHtml.
19 20 21 22 23 |
# File 'lib/clickwrap/receipt_html.rb', line 19 def initialize(receipt, view_context: nil, body: nil) @receipt = receipt @view_context = view_context @body = body || receipt.to_h end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
25 26 27 |
# File 'lib/clickwrap/receipt_html.rb', line 25 def body @body end |
#receipt ⇒ Object (readonly)
Returns the value of attribute receipt.
25 26 27 |
# File 'lib/clickwrap/receipt_html.rb', line 25 def receipt @receipt end |
Instance Method Details
#render ⇒ Object
27 28 29 |
# File 'lib/clickwrap/receipt_html.rb', line 27 def render ERB.new(TEMPLATE, trim_mode: "-").result(binding) end |