Sha256: 46baba9b9052a1f9a1900280fc569be9bbce0b2d212a539824025b4babbace33

Contents?: true

Size: 801 Bytes

Versions: 50

Compression:

Stored size: 801 Bytes

Contents

module Avromatic
  module Model
    module AttributeType

      # This class is used as the base class for Virtus attributes that
      # represent unions. A subclass is generated using Union[*types]. This
      # subclass is specified when defining a Virtus attribute.
      class Union
        class << self
          attr_reader :types

          protected

          attr_writer :types
        end

        # Factory method to define Union types with the specified list of
        # types (classes).
        def self.[](*types)
          Class.new(self).tap do |klass|
            klass.types = types
            # See https://github.com/solnic/virtus/issues/284#issuecomment-56405137
            Axiom::Types::Object.new { primitive(klass) }
          end
        end
      end
    end
  end
end

Version data entries

50 entries across 50 versions & 1 rubygems

Version Path
avromatic-0.10.0.rc1 lib/avromatic/model/attribute_type/union.rb
avromatic-0.10.0.rc0 lib/avromatic/model/attribute_type/union.rb
avromatic-0.9.0 lib/avromatic/model/attribute_type/union.rb
avromatic-0.9.0.rc7 lib/avromatic/model/attribute_type/union.rb
avromatic-0.9.0.rc6 lib/avromatic/model/attribute_type/union.rb
avromatic-0.9.0.rc4 lib/avromatic/model/attribute_type/union.rb
avromatic-0.9.0.rc3 lib/avromatic/model/attribute_type/union.rb
avromatic-0.9.0.rc2 lib/avromatic/model/attribute_type/union.rb
avromatic-0.9.0.rc1 lib/avromatic/model/attribute_type/union.rb
avromatic-0.9.0.rc0 lib/avromatic/model/attribute_type/union.rb