Class: Puppet::Pops::Types::PIteratorType

Inherits:
PTypeWithContainedType show all
Defined in:
lib/puppet/pops/types/types.rb

Constant Summary collapse

DEFAULT =
PIteratorType.new(nil)

Instance Attribute Summary

Attributes inherited from PTypeWithContainedType

#type

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from PTypeWithContainedType

#accept, #eql?, #generalize, #hash, #initialize, #normalize, #resolve

Methods inherited from PAnyType

#==, #accept, #assignable?, #callable?, #callable_args?, #callable_with?, #check_self_recursion, create, #create, #eql?, #generalize, #hash, #kind_of_callable?, #loader, #name, #new_function, new_function, #normalize, #really_instance?, #resolve, #roundtrip_with_string?, #simple_name, simple_name, #to_alias_expanded_s, #to_s

Methods inherited from TypedModelObject

_pcore_type, create_ptype, register_ptypes

Methods included from Visitable

#accept

Methods included from PuppetObject

#_pcore_all_contents, #_pcore_contents, #_pcore_init_hash, #_pcore_type, #to_s

Constructor Details

This class inherits a constructor from Puppet::Pops::Types::PTypeWithContainedType

Class Method Details

.register_ptype(loader, ir) ⇒ Object



1460
1461
1462
1463
1464
1465
1466
1467
# File 'lib/puppet/pops/types/types.rb', line 1460

def self.register_ptype(loader, ir)
  create_ptype(loader, ir, 'AnyType',
    'type' => {
      KEY_TYPE => POptionalType.new(PTypeType::DEFAULT),
      KEY_VALUE => nil
    }
  )
end

Instance Method Details

#element_typeObject



1469
1470
1471
# File 'lib/puppet/pops/types/types.rb', line 1469

def element_type
  @type
end

#instance?(o, guard = nil) ⇒ Boolean

Returns:

  • (Boolean)


1473
1474
1475
# File 'lib/puppet/pops/types/types.rb', line 1473

def instance?(o, guard = nil)
  o.is_a?(Iterable) && (@type.nil? || @type.assignable?(o.element_type, guard))
end

#iterable?(guard = nil) ⇒ Boolean

Returns:

  • (Boolean)


1477
1478
1479
# File 'lib/puppet/pops/types/types.rb', line 1477

def iterable?(guard = nil)
  true
end

#iterable_type(guard = nil) ⇒ Object



1481
1482
1483
# File 'lib/puppet/pops/types/types.rb', line 1481

def iterable_type(guard = nil)
  @type.nil? ? PIterableType::DEFAULT : PIterableType.new(@type)
end