Sha256: 74c6a91aef6a99c5fa068eb9c1560592e0cde5e088e2f1f46383892898bc06e6

Contents?: true

Size: 977 Bytes

Versions: 2

Compression:

Stored size: 977 Bytes

Contents

require 'ivy/serializers/registry'

module Ivy
  module Serializers
    class Serializer
      class << self
        attr_accessor :_registry

        def attributes(generator, resource)
          _registry.attributes(generator, resource)
        end

        def inherited(base)
          base._registry = Registry.new
        end

        def relationships(generator, resource)
          _registry.relationships(generator, resource)
        end

        def map(klass, &block)
          _registry.map(klass, &block)
        end

        def resource(generator, resource)
          _registry.resource(generator, resource)
        end
      end

      def attributes(generator, resource)
        self.class.attributes(generator, resource)
      end

      def relationships(generator, resource)
        self.class.relationships(generator, resource)
      end

      def resource(generator, resource)
        self.class.resource(generator, resource)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ivy-serializers-0.4.0 lib/ivy/serializers/serializer.rb
ivy-serializers-0.3.0 lib/ivy/serializers/serializer.rb