class Yadriggy::OptionalRole

A role that can be attached to a {Type} object. It makes a chain of {Type} objects.

Public Class Methods

new(type) click to toggle source

@param [Type] type a Type object that this role is added to.

# File lib/yadriggy/type.rb, line 635
def initialize(type)
  @type = type
end

Public Instance Methods

<=(t) click to toggle source

@api private

# File lib/yadriggy/type.rb, line 672
def <= (t)
  @type <= t
end
==(t) click to toggle source

Checks the equality. The roles (a {OptionalRole} objects) in the chain are ignored when objects are compared.

# File lib/yadriggy/type.rb, line 662
def == (t)
  @type == t
end
copy(without_role) click to toggle source

@api private

# File lib/yadriggy/type.rb, line 640
def copy(without_role)
  chain = @type.copy(without_role)
  if self.is_a?(without_role)
    chain
  else
    if @type.equal?(chain)
      self
    else
      new_self = self.clone()
      new_self.update_type = chain
      new_self
    end
  end
end
exact_type() click to toggle source

@api private

# File lib/yadriggy/type.rb, line 691
def exact_type
  @type.exact_type
end
get_method_object(method_name) click to toggle source

@api private

# File lib/yadriggy/type.rb, line 696
def get_method_object(method_name)
  Type.get_instance_method_object(@type, method_name)
end
has_role?(a_role) click to toggle source

@api private

# File lib/yadriggy/type.rb, line 682
def has_role?(a_role)
  if self.is_a?(a_role)
    self
  else
    @type.has_role?(a_role)
  end
end
hash() click to toggle source

@api private

# File lib/yadriggy/type.rb, line 667
def hash
  @type.hash
end
is_super_of?(t) click to toggle source

@api private

# File lib/yadriggy/type.rb, line 677
def is_super_of?(t)
  @type.is_super_of?(t)
end
supertype() click to toggle source

@return [Type] the super type.

# File lib/yadriggy/type.rb, line 701
def supertype
  @type.supertype
end
update_type(t) click to toggle source

@api private

# File lib/yadriggy/type.rb, line 656
def update_type(t)
  @type = t
end