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.19.0 lib/avromatic/model/attribute_type/union.rb
avromatic-0.18.1 lib/avromatic/model/attribute_type/union.rb
avromatic-0.18.0 lib/avromatic/model/attribute_type/union.rb
avromatic-0.18.0.rc0 lib/avromatic/model/attribute_type/union.rb
avromatic-0.17.1 lib/avromatic/model/attribute_type/union.rb
avromatic-0.17.0 lib/avromatic/model/attribute_type/union.rb
avromatic-0.15.1 lib/avromatic/model/attribute_type/union.rb
avromatic-0.15.0 lib/avromatic/model/attribute_type/union.rb
avromatic-0.15.0.rc0 lib/avromatic/model/attribute_type/union.rb
avromatic-0.14.0 lib/avromatic/model/attribute_type/union.rb
avromatic-0.14.0.rc1 lib/avromatic/model/attribute_type/union.rb
avromatic-0.14.0.rc0 lib/avromatic/model/attribute_type/union.rb
avromatic-0.13.0 lib/avromatic/model/attribute_type/union.rb
avromatic-0.13.0.rc1 lib/avromatic/model/attribute_type/union.rb
avromatic-0.13.0.rc0 lib/avromatic/model/attribute_type/union.rb
avromatic-0.12.0 lib/avromatic/model/attribute_type/union.rb
avromatic-0.11.2 lib/avromatic/model/attribute_type/union.rb
avromatic-0.11.1 lib/avromatic/model/attribute_type/union.rb
avromatic-0.11.0 lib/avromatic/model/attribute_type/union.rb
avromatic-0.10.0 lib/avromatic/model/attribute_type/union.rb