Module: Puppet::Pops::Types::Annotatable

Included in:
PMetaType, PObjectType::PAnnotatedMember, TypeSetReference
Defined in:
lib/puppet/pops/types/annotatable.rb

Overview

Behaviour common to all Pcore annotatable classes

Constant Summary collapse

TYPE_ANNOTATIONS =
PHashType.new(PTypeType.new(PTypeReferenceType.new('Annotation')), PHashType::DEFAULT)

Instance Method Summary collapse

Instance Method Details

#_pcore_init_hashObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



29
30
31
32
33
# File 'lib/puppet/pops/types/annotatable.rb', line 29

def _pcore_init_hash
  result = {}
  result[KEY_ANNOTATIONS] = @annotations unless @annotations.nil?
  result
end

#annotatable_accept(visitor, guard) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



24
25
26
# File 'lib/puppet/pops/types/annotatable.rb', line 24

def annotatable_accept(visitor, guard)
  @annotations.each_key { |key| key.accept(visitor, guard) } unless @annotations.nil?
end

#annotations{PTypeType => PStructType}

Returns the map of annotations.

Returns:



14
15
16
# File 'lib/puppet/pops/types/annotatable.rb', line 14

def annotations
  @annotations.nil? ? EMPTY_HASH : @annotations
end

#init_annotatable(init_hash) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



19
20
21
# File 'lib/puppet/pops/types/annotatable.rb', line 19

def init_annotatable(init_hash)
  @annotations = init_hash[KEY_ANNOTATIONS].freeze
end