Class: Puppet::Pops::Types::PResourceType

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

Overview

Represents a Resource Type in the Puppet Language

Constant Summary collapse

DEFAULT =
PResourceType.new(nil)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from PCatalogEntryType

#instance?

Methods inherited from PAnyType

#==, #accept, #assignable?, #callable?, #callable_args?, #callable_with?, #check_self_recursion, create, #create, #generalize, #instance?, #iterable?, #iterable_type, #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

Constructor Details

#initialize(type_name, title = nil) ⇒ PResourceType

Returns a new instance of PResourceType.



3096
3097
3098
3099
3100
# File 'lib/puppet/pops/types/types.rb', line 3096

def initialize(type_name, title = nil)
  @type_name = type_name.freeze
  @title = title.freeze
  @downcased_name = type_name.nil? ? nil : @type_name.downcase.freeze
end

Instance Attribute Details

#downcased_nameObject (readonly)



3094
3095
3096
# File 'lib/puppet/pops/types/types.rb', line 3094

def downcased_name
  @downcased_name
end

#titleObject (readonly)



3094
3095
3096
# File 'lib/puppet/pops/types/types.rb', line 3094

def title
  @title
end

#type_nameObject (readonly)



3094
3095
3096
# File 'lib/puppet/pops/types/types.rb', line 3094

def type_name
  @type_name
end

Class Method Details

.register_ptype(loader, ir) ⇒ Object



3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
# File 'lib/puppet/pops/types/types.rb', line 3081

def self.register_ptype(loader, ir)
  create_ptype(loader, ir, 'CatalogEntryType',
    'type_name' => {
      KEY_TYPE => POptionalType.new(PStringType::NON_EMPTY),
      KEY_VALUE => nil
    },
    'title' => {
      KEY_TYPE => POptionalType.new(PStringType::NON_EMPTY),
      KEY_VALUE => nil
    }
  )
end

Instance Method Details

#eql?(o) ⇒ Boolean

Returns:

  • (Boolean)


3102
3103
3104
# File 'lib/puppet/pops/types/types.rb', line 3102

def eql?(o)
  self.class == o.class && @downcased_name == o.downcased_name && @title == o.title
end

#hashObject



3106
3107
3108
# File 'lib/puppet/pops/types/types.rb', line 3106

def hash
  @downcased_name.hash ^ @title.hash
end