Class: Norma43::Models::Document
- Inherits:
-
Object
- Object
- Norma43::Models::Document
- Includes:
- Mixins::AttributesAssignment
- Defined in:
- lib/norma43/models/document.rb
Constant Summary
Constants included from Mixins::AttributesAssignment
Mixins::AttributesAssignment::EMPTY_ATTRIBUTES
Instance Attribute Summary collapse
-
#accounts ⇒ Object
Returns the value of attribute accounts.
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#delivery_number ⇒ Object
Returns the value of attribute delivery_number.
-
#file_type ⇒ Object
Returns the value of attribute file_type.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#number_of_lines ⇒ Object
Returns the value of attribute number_of_lines.
Instance Method Summary collapse
-
#initialize(attributes = EMPTY_ATTRIBUTES) ⇒ Document
constructor
A new instance of Document.
-
#transaction_date ⇒ Object
deprecated
Deprecated.
Please ask each transaction inside accounts for their transaction_date instead
Methods included from Mixins::AttributesAssignment
Constructor Details
#initialize(attributes = EMPTY_ATTRIBUTES) ⇒ Document
Returns a new instance of Document.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/norma43/models/document.rb', line 10 def initialize(attributes = EMPTY_ATTRIBUTES) @id, @created_at, @delivery_number, @file_type, @name, @number_of_lines, accounts = Hash(attributes).values_at( :id, :created_at, :delivery_number, :file_type, :name, :number_of_lines, :accounts) @accounts = Array(accounts).map { |account| Account.new(account) } end |
Instance Attribute Details
#accounts ⇒ Object
Returns the value of attribute accounts.
8 9 10 |
# File 'lib/norma43/models/document.rb', line 8 def accounts @accounts end |
#created_at ⇒ Object
Returns the value of attribute created_at.
8 9 10 |
# File 'lib/norma43/models/document.rb', line 8 def created_at @created_at end |
#delivery_number ⇒ Object
Returns the value of attribute delivery_number.
8 9 10 |
# File 'lib/norma43/models/document.rb', line 8 def delivery_number @delivery_number end |
#file_type ⇒ Object
Returns the value of attribute file_type.
8 9 10 |
# File 'lib/norma43/models/document.rb', line 8 def file_type @file_type end |
#id ⇒ Object
Returns the value of attribute id.
8 9 10 |
# File 'lib/norma43/models/document.rb', line 8 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
8 9 10 |
# File 'lib/norma43/models/document.rb', line 8 def name @name end |
#number_of_lines ⇒ Object
Returns the value of attribute number_of_lines.
8 9 10 |
# File 'lib/norma43/models/document.rb', line 8 def number_of_lines @number_of_lines end |
Instance Method Details
#transaction_date ⇒ Object
Please ask each transaction inside accounts for their transaction_date instead
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/norma43/models/document.rb', line 29 def transaction_date warn "[DEPRECATION] `transaction_date` is deprecated, use `#transaction_date` from transactions in `#accounts` instead" date = nil accounts.flat_map(&:transactions).each { |transaction| date = transaction&.transaction_date break unless date.nil? } date end |