Sha256: d69fe21cdb99dcaed2fcbc019cd140d67dbd53e37e5b1d1b203cb95282f21e16

Contents?: true

Size: 955 Bytes

Versions: 1

Compression:

Stored size: 955 Bytes

Contents

# frozen_string_literal: true

require 'virtus'
require 'json'

# Namespace for the Opushon library.
# Representation of documentations for HTTP APIs.
#
# @api private
module Opushon
  # Load opushon in to the Ruby data structure.
  #
  # @api public
  #
  # @example Load the option of a DELETE interface
  #   load('{"DELETE":{"title":"Delete issues","description":"Remove every issues.","request":{"headers":{},"query_string":{},"body":{}},"response":{"headers":{},"query_string":{},"body":{}}}}')
  #
  # @param [String] opushon_string
  #
  # @return [Body] the Ruby data structure
  def self.load(opushon_string)
    opushon_hash = JSON.parse(opushon_string)
    Body.new(opushon_hash)
  end

  # Dump Ruby object to a Opushon string.
  #
  # @api public
  #
  # @param [Body] opushon
  #
  # @return [String] the Opushon data representation
  def self.dump(opushon)
    opushon.to_h.to_json
  end
end

require_relative File.join('opushon', 'body')

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
opushon-0.2.2 lib/opushon.rb