Class: Goodsheet::ReadResult
- Inherits:
-
Object
- Object
- Goodsheet::ReadResult
- Defined in:
- lib/goodsheet/read_result.rb
Instance Attribute Summary collapse
-
#values ⇒ Object
readonly
Returns the value of attribute values.
Instance Method Summary collapse
- #add(attribute, row, force_nil = nil) ⇒ Object
- #errors ⇒ Object
-
#initialize(errors = ValidationErrors.new) ⇒ ReadResult
constructor
A new instance of ReadResult.
- #invalid? ⇒ Boolean
- #valid? ⇒ Boolean
Constructor Details
#initialize(errors = ValidationErrors.new) ⇒ ReadResult
Returns a new instance of ReadResult.
6 7 8 9 |
# File 'lib/goodsheet/read_result.rb', line 6 def initialize(errors=ValidationErrors.new) @errors = errors @values = {} end |
Instance Attribute Details
#values ⇒ Object (readonly)
Returns the value of attribute values.
4 5 6 |
# File 'lib/goodsheet/read_result.rb', line 4 def values @values end |
Instance Method Details
#add(attribute, row, force_nil = nil) ⇒ Object
19 20 21 22 |
# File 'lib/goodsheet/read_result.rb', line 19 def add(attribute, row, force_nil=nil) attribute = attribute.to_sym (@values[attribute] ||= []) << (row.send(attribute) || force_nil) end |
#errors ⇒ Object
24 25 26 |
# File 'lib/goodsheet/read_result.rb', line 24 def errors @errors.array end |
#invalid? ⇒ Boolean
15 16 17 |
# File 'lib/goodsheet/read_result.rb', line 15 def invalid? !valid? end |
#valid? ⇒ Boolean
11 12 13 |
# File 'lib/goodsheet/read_result.rb', line 11 def valid? @errors.empty? end |