Class: Tobacco::ContentValidator
- Inherits:
-
Object
- Object
- Tobacco::ContentValidator
- Defined in:
- lib/tobacco/content_validator.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
Instance Method Summary collapse
-
#initialize(smoker) ⇒ ContentValidator
constructor
A new instance of ContentValidator.
-
#validate! ⇒ Object
Public: Verifies that content is present and calls continue_write on the Smoker class if so and notifies the consumer class of the read error if not.
Constructor Details
#initialize(smoker) ⇒ ContentValidator
Returns a new instance of ContentValidator.
11 12 13 14 |
# File 'lib/tobacco/content_validator.rb', line 11 def initialize(smoker) @smoker = smoker self.content = smoker.content end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
9 10 11 |
# File 'lib/tobacco/content_validator.rb', line 9 def content @content end |
Instance Method Details
#validate! ⇒ Object
Public: Verifies that content is present and calls
continue_write on the Smoker class if so
and notifies the consumer class of the
read error if not
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/tobacco/content_validator.rb', line 21 def validate! if content_present? @smoker.continue_write else # ????? IS this still true # # At this point, the content might be an error object # but if not, we create one # object = missing_content_error(content) error = error_object('Error Reading', object) Tobacco::Callback.instance.notify(:on_read_error, error) end end |