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?, #check_self_recursion, #generalize, #instance?, #iterable?, #iterable_type, #kind_of_callable?, #name, #new_function, new_function, #normalize, #really_instance?, #resolve, #simple_name, simple_name, #to_alias_expanded_s, #to_s

Methods inherited from TypedModelObject

_ptype, create_ptype, register_ptypes

Methods included from Visitable

#accept

Methods included from PuppetObject

#_ptype

Constructor Details

#initialize(type_name, title = nil) ⇒ PResourceType

Returns a new instance of PResourceType.



2855
2856
2857
2858
2859
# File 'lib/puppet/pops/types/types.rb', line 2855

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)



2853
2854
2855
# File 'lib/puppet/pops/types/types.rb', line 2853

def downcased_name
  @downcased_name
end

#titleObject (readonly)



2853
2854
2855
# File 'lib/puppet/pops/types/types.rb', line 2853

def title
  @title
end

#type_nameObject (readonly)



2853
2854
2855
# File 'lib/puppet/pops/types/types.rb', line 2853

def type_name
  @type_name
end

Class Method Details

.register_ptype(loader, ir) ⇒ Object



2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
# File 'lib/puppet/pops/types/types.rb', line 2840

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)


2861
2862
2863
# File 'lib/puppet/pops/types/types.rb', line 2861

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

#hashObject



2865
2866
2867
# File 'lib/puppet/pops/types/types.rb', line 2865

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