Sha256: 7e373c0027bef53554b90167d78a3ea43e6ce8b2b6e7755890b89d6ba25b9ad7

Contents?: true

Size: 635 Bytes

Versions: 1

Compression:

Stored size: 635 Bytes

Contents

# coding: utf-8
require 'aepic'

module Aepic
  module Concerns
    module Serializer
      attributes :id

      XSD_TYPES = Hash.new { |hash, key| hash[key] = "xsd:#{key}"}.merge({
      })

      def self.jsonld_context
        {}.tap do |context|
          schema[:attributes].each do |name, type|
            context[name] = XSD_TYPES[type]
          end
        end
      end

      def self.jsonld
        {'@context' => jsonld_context.merge(xsd: 'http://www.w3.org/2001/XMLSchema#')}
      end

      def attributes
        hash = super
        hash['@context'] = object.jsonld_context
        hash
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aepic-0.0.1 lib/aepic/concerns/serializer.rb