Class: Ksef::FA3::Attachment
- Inherits:
-
Data
- Object
- Data
- Ksef::FA3::Attachment
- Includes:
- Canonical
- Defined in:
- lib/ksef/fa3/attachment.rb,
lib/ksef/fa3/attachment.rb
Overview
Construction, invariants and serialisation for Attachment.
Constant Summary collapse
- NEEDS_BLOCK =
"An attachment needs at least one data block. `BlokDanych` is minOccurs=1 " \ "within `Zalacznik`, so an attachment without one cannot be serialised."
Instance Attribute Summary collapse
-
#blocks ⇒ Object
readonly
Returns the value of attribute blocks.
Class Method Summary collapse
-
.wrap(value) ⇒ Object
An Attachment, or the blocks to make one from.
Instance Method Summary collapse
-
#initialize(blocks:) ⇒ Attachment
constructor
A new instance of Attachment.
- #to_fa3 ⇒ Object
Methods included from Canonical
Constructor Details
#initialize(blocks:) ⇒ Attachment
Returns a new instance of Attachment.
29 30 31 32 33 34 |
# File 'lib/ksef/fa3/attachment.rb', line 29 def initialize(blocks:) entries = Correction.wrap(blocks) raise ValidationError, NEEDS_BLOCK if entries.empty? super(blocks: entries.dup.freeze) end |
Instance Attribute Details
#blocks ⇒ Object (readonly)
Returns the value of attribute blocks
17 18 19 |
# File 'lib/ksef/fa3/attachment.rb', line 17 def blocks @blocks end |
Class Method Details
.wrap(value) ⇒ Object
An Ksef::FA3::Attachment, or the blocks to make one from. The one-block case is the common one and does not deserve two levels of ceremony; Builder#attachment is the caller.
38 |
# File 'lib/ksef/fa3/attachment.rb', line 38 def self.wrap(value) = value.is_a?(Attachment) ? value : new(blocks: value) |
Instance Method Details
#to_fa3 ⇒ Object
40 |
# File 'lib/ksef/fa3/attachment.rb', line 40 def to_fa3 = { "BlokDanych" => blocks.map(&:to_fa3) } |