Class: TSJSON::Merge

Inherits:
Base
  • Object
show all
Defined in:
lib/types/merge.rb

Direct Known Subclasses

Intersection, Union

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#compile, #index, #property, #valid?

Constructor Details

#initialize(types = [], is_normal = false) ⇒ Merge

Returns a new instance of Merge.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/types/merge.rb', line 6

def initialize(types = [], is_normal = false)
  super()

  types.each do |t|
    unless t.is_a?(ObjectType) || t.is_a?(Union) || t.is_a?(Intersection)
      raise "#{
              self.class.name
            } may contain only ObjectType, Union or Intersection types"
    end
  end

  @types = types
  @is_normal = types.length == 0 || is_normal
end

Instance Attribute Details

#is_normalObject

Returns the value of attribute is_normal.



4
5
6
# File 'lib/types/merge.rb', line 4

def is_normal
  @is_normal
end

#typesObject (readonly)

Returns the value of attribute types.



3
4
5
# File 'lib/types/merge.rb', line 3

def types
  @types
end