Sha256: 64e5ca55207fe5a4f4741df13484dd5046201d0e587bc22a53fdeec4b5476fe3

Contents?: true

Size: 448 Bytes

Versions: 2

Compression:

Stored size: 448 Bytes

Contents

class Taro::Types::ObjectTypes::FreeFormType < Taro::Types::ObjectType
  self.desc = 'An arbitrary, unvalidated Hash or JSON object. Use with care.'
  self.additional_properties = true

  def coerce_input
    object.is_a?(Hash) && object || input_error('must be a Hash')
  end

  def coerce_response
    object.respond_to?(:as_json) && (res = object.as_json).is_a?(Hash) && res ||
      response_error('must return a Hash from #as_json')
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
taro-1.1.0 lib/taro/types/object_types/free_form_type.rb
taro-1.0.0 lib/taro/types/object_types/free_form_type.rb