Class: Canvas::Validator::Json
- Inherits:
-
Object
- Object
- Canvas::Validator::Json
- Defined in:
- lib/canvas/validators/json.rb
Overview
:documented:
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Instance Method Summary collapse
-
#initialize(file) ⇒ Json
constructor
A new instance of Json.
- #validate ⇒ Object
Constructor Details
#initialize(file) ⇒ Json
Returns a new instance of Json.
11 12 13 |
# File 'lib/canvas/validators/json.rb', line 11 def initialize(file) @file = file end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
9 10 11 |
# File 'lib/canvas/validators/json.rb', line 9 def errors @errors end |
Instance Method Details
#validate ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/canvas/validators/json.rb', line 15 def validate ::JSON.parse(@file) true rescue ::JSON::ParserError => e @errors = [e.] false end |