Class: InferModel::Parsers::JSON
- Inherits:
-
Object
- Object
- InferModel::Parsers::JSON
- Extended by:
- Dry::Initializer, Callable
- Defined in:
- lib/infer_model/parsers/json.rb
Instance Method Summary collapse
Instance Method Details
#call ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/infer_model/parsers/json.rb', line 13 def call raise Parsers::Error, "value was blank which is not allowed" if value.nil? && !allow_blank return if value.nil? || value.empty? JSON.parse(value) rescue JSON::ParserError raise Parsers::Error, "'#{value}' is not a JSON" end |