Class: Rubyang::Database::SchemaTree::UnionType

Inherits:
Type
  • Object
show all
Defined in:
lib/rubyang/database/schema_tree.rb

Instance Attribute Summary

Attributes inherited from Type

#arg

Instance Method Summary collapse

Constructor Details

#initializeUnionType

Returns a new instance of UnionType.



201
202
203
204
# File 'lib/rubyang/database/schema_tree.rb', line 201

def initialize
  @arg = 'union'
  @types = Array.new
end

Instance Method Details

#add_type(type) ⇒ Object



205
206
207
# File 'lib/rubyang/database/schema_tree.rb', line 205

def add_type type
  @types.push type
end

#valid?(value) ⇒ Boolean

Returns:

  • (Boolean)


208
209
210
211
212
# File 'lib/rubyang/database/schema_tree.rb', line 208

def valid? value
  result = false
  result ||= @types.inject( false ){ |r, t| r || t.valid?( value ) }
  result
end