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-1.0.0 lib/avromatic/model/attribute_type/union.rb
avromatic-0.33.0 lib/avromatic/model/attribute_type/union.rb
avromatic-0.32.0 lib/avromatic/model/attribute_type/union.rb
avromatic-0.32.0.rc0 lib/avromatic/model/attribute_type/union.rb
avromatic-0.31.0 lib/avromatic/model/attribute_type/union.rb
avromatic-0.30.0 lib/avromatic/model/attribute_type/union.rb
avromatic-0.29.1 lib/avromatic/model/attribute_type/union.rb
avromatic-0.29.0 lib/avromatic/model/attribute_type/union.rb
avromatic-0.28.1 lib/avromatic/model/attribute_type/union.rb
avromatic-0.27.0 lib/avromatic/model/attribute_type/union.rb
avromatic-0.26.0 lib/avromatic/model/attribute_type/union.rb
avromatic-0.25.0 lib/avromatic/model/attribute_type/union.rb
avromatic-0.24.0 lib/avromatic/model/attribute_type/union.rb
avromatic-0.23.0 lib/avromatic/model/attribute_type/union.rb
avromatic-0.22.0 lib/avromatic/model/attribute_type/union.rb
avromatic-0.21.1 lib/avromatic/model/attribute_type/union.rb
avromatic-0.21.0 lib/avromatic/model/attribute_type/union.rb
avromatic-0.21.0.rc1 lib/avromatic/model/attribute_type/union.rb
avromatic-0.21.0.rc0 lib/avromatic/model/attribute_type/union.rb
avromatic-0.20.0 lib/avromatic/model/attribute_type/union.rb