Class: Grape::Validations::Types::JsonArray
- Defined in:
- lib/grape/validations/types/json.rb
Overview
Specialization of the Json attribute that is guaranteed to return an array of objects. Accepts both JSON-encoded objects and arrays of objects, but wraps single objects in an Array.
Instance Method Summary collapse
-
#call(input) ⇒ Array<Hash>
See Json#coerce.
-
#coerced?(value) ⇒ Boolean
See Grape::Validations::Types::Json#coerced_collection?.
Instance Method Details
#call(input) ⇒ Array<Hash>
See Json#coerce. Wraps single objects in an array.
56 57 58 59 |
# File 'lib/grape/validations/types/json.rb', line 56 def call(input) json = super Array.wrap(json) unless json.nil? end |
#coerced?(value) ⇒ Boolean
See Grape::Validations::Types::Json#coerced_collection?
62 63 64 |
# File 'lib/grape/validations/types/json.rb', line 62 def coerced?(value) coerced_collection? value end |