class Yoda::Model::Types::UnionType
Attributes
types[R]
Public Class Methods
new(types)
click to toggle source
@param types [Array<Base>] @return [Base]
Calls superclass method
# File lib/yoda/model/types/union_type.rb, line 11 def self.new(types) reduced_types = types.reject { |type| type.is_a?(AnyType) || type.is_a?(UnknownType) }.uniq return (types.first || AnyType.new) if reduced_types.length == 0 return reduced_types.first if reduced_types.length == 1 super(reduced_types) end
new(types)
click to toggle source
@param types [Array<Base>]
# File lib/yoda/model/types/union_type.rb, line 19 def initialize(types) @types = types end
Public Instance Methods
change_root(paths)
click to toggle source
@param paths [Array<Path>] @return [self]
# File lib/yoda/model/types/union_type.rb, line 34 def change_root(paths) self.class.new(types.map { |type| type.change_root(paths) }) end
eql?(another)
click to toggle source
# File lib/yoda/model/types/union_type.rb, line 23 def eql?(another) another.is_a?(UnionType) && Set.new(types) == Set.new(another.types) end
hash()
click to toggle source
# File lib/yoda/model/types/union_type.rb, line 28 def hash [self.class.name, Set.new(types)].hash end
map(&block)
click to toggle source
@return [self]
# File lib/yoda/model/types/union_type.rb, line 50 def map(&block) self.class.new(types.map(&block)) end
resolve(registry)
click to toggle source
@param registry [Registry] @return [Array<Store::Objects::Base>]
# File lib/yoda/model/types/union_type.rb, line 40 def resolve(registry) types.map { |type| type.resolve(registry) }.flatten.compact end
to_s()
click to toggle source
@return [String]
# File lib/yoda/model/types/union_type.rb, line 45 def to_s types.map(&:to_s).join(' | ') end