Sha256: b614ac33ff6b5e8632c64f6a7212799fe193dea428cad597af4fad7ec9913d61

Contents?: true

Size: 801 Bytes

Versions: 2

Compression:

Stored size: 801 Bytes

Contents

require 'fun_with_json_api/exception'
require 'fun_with_json_api/attribute'

require 'fun_with_json_api/pre_deserializer'
require 'fun_with_json_api/deserializer'
require 'fun_with_json_api/deserializer_config_builder'

# Makes working with JSON:API fun!
module FunWithJsonApi
  module_function

  def deserialize(api_document, deserializer_class, options = {})
    # Prepare the deserializer and the expected config
    deserializer = deserializer_class.create(options)

    # Run through initial document structure validation and deserialization
    unfiltered = FunWithJsonApi::PreDeserializer.parse(api_document, deserializer)

    # Ensure document matches schema, and sanitize values
    deserializer.sanitize_params(unfiltered)
  end
end

require 'fun_with_json_api/railtie' if defined?(Rails)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fun_with_json_api-0.0.2 lib/fun_with_json_api.rb
fun_with_json_api-0.0.1 lib/fun_with_json_api.rb