Class: Canvas::Validator::Json

Inherits:
Object
  • Object
show all
Defined in:
lib/canvas/validators/json.rb

Overview

:documented:

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#errorsObject (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

#validateObject



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.message]
  false
end