Class: Puppet::Pops::Types::PMetaType
- Inherits:
-
PAnyType
- Object
- TypedModelObject
- PAnyType
- Puppet::Pops::Types::PMetaType
- Includes:
- Annotatable
- Defined in:
- lib/puppet/pops/types/p_meta_type.rb
Direct Known Subclasses
Constant Summary
Constants included from Annotatable
Annotatable::TYPE_ANNOTATIONS, Annotatable::TYPE_ANNOTATION_KEY_TYPE, Annotatable::TYPE_ANNOTATION_VALUE_TYPE
Constants inherited from PAnyType
Puppet::Pops::Types::PAnyType::DEFAULT
Instance Attribute Summary
Attributes included from Annotatable
Class Method Summary collapse
Instance Method Summary collapse
- #accept(visitor, guard) ⇒ Object
-
#resolve(type_parser, loader) ⇒ PTypeAliasType
private
Called from the TypeParser once it has found a type using the Loader.
- #resolve_hash(type_parser, loader, i12n_hash) ⇒ Object
- #resolve_literal_hash(type_parser, loader, i12n_hash_expression) ⇒ Object
- #resolve_type_refs(type_parser, loader, o) ⇒ Object
-
#to_s ⇒ String
Returns the expanded string the form of the alias, e.g.
Methods included from Annotatable
#annotatable_accept, #i12n_hash, #init_annotatable
Methods inherited from PAnyType
#==, #assignable?, #callable?, #callable_args?, #check_self_recursion, #eql?, #generalize, #hash, #instance?, #iterable?, #iterable_type, #kind_of_callable?, #name, #new_function, new_function, #normalize, #really_instance?, #simple_name, simple_name, #to_alias_expanded_s
Methods inherited from TypedModelObject
_ptype, create_ptype, register_ptypes
Methods included from PuppetObject
Class Method Details
.register_ptype(loader, ir) ⇒ Object
13 14 15 |
# File 'lib/puppet/pops/types/p_meta_type.rb', line 13 def self.register_ptype(loader, ir) # Abstract type. It doesn't register anything end |
Instance Method Details
#accept(visitor, guard) ⇒ Object
17 18 19 20 |
# File 'lib/puppet/pops/types/p_meta_type.rb', line 17 def accept(visitor, guard) annotatable_accept(visitor, guard) super end |
#resolve(type_parser, loader) ⇒ PTypeAliasType
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.
Called from the TypeParser once it has found a type using the Loader. The TypeParser will interpret the contained expression and the resolved type is remembered. This method also checks and remembers if the resolve type contains self recursion.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/puppet/pops/types/p_meta_type.rb', line 30 def resolve(type_parser, loader) unless @i12n_hash_expression.nil? @self_recursion = true # assumed while it being found out below i12n_hash_expression = @i12n_hash_expression @i12n_hash_expression = nil if i12n_hash_expression.is_a?(Model::LiteralHash) i12n_hash = resolve_literal_hash(type_parser, loader, i12n_hash_expression) else i12n_hash = resolve_hash(type_parser, loader, i12n_hash_expression) end initialize_from_hash(i12n_hash) # Find out if this type is recursive. A recursive type has performance implications # on several methods and this knowledge is used to avoid that for non-recursive # types. guard = RecursionGuard.new accept(NoopTypeAcceptor::INSTANCE, guard) @self_recursion = guard.recursive_this?(self) end self end |
#resolve_hash(type_parser, loader, i12n_hash) ⇒ Object
57 58 59 |
# File 'lib/puppet/pops/types/p_meta_type.rb', line 57 def resolve_hash(type_parser, loader, i12n_hash) resolve_type_refs(type_parser, loader, i12n_hash) end |
#resolve_literal_hash(type_parser, loader, i12n_hash_expression) ⇒ Object
53 54 55 |
# File 'lib/puppet/pops/types/p_meta_type.rb', line 53 def resolve_literal_hash(type_parser, loader, i12n_hash_expression) type_parser.interpret_LiteralHash(i12n_hash_expression, loader) end |
#resolve_type_refs(type_parser, loader, o) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/puppet/pops/types/p_meta_type.rb', line 61 def resolve_type_refs(type_parser, loader, o) case o when Hash Hash[o.map { |k, v| [resolve_type_refs(type_parser, loader, k), resolve_type_refs(type_parser, loader, v)] }] when Array o.map { |e| resolve_type_refs(type_parser, loader, e) } when PAnyType o.resolve(type_parser, loader) else o end end |
#to_s ⇒ String
Returns the expanded string the form of the alias, e.g. <alias name> = <resolved type>
78 79 80 |
# File 'lib/puppet/pops/types/p_meta_type.rb', line 78 def to_s TypeFormatter.singleton.(self) end |