Class: RDoc::PuppetClass

Inherits:
ClassModule
  • Object
show all
Includes:
AddClassModuleComment
Defined in:
lib/puppet/util/rdoc/code_objects.rb

Overview

PuppetClass holds a puppet class It is mapped to a HTMLPuppetClass for display It leverages RDoc (ruby) Class

Direct Known Subclasses

PuppetNode

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from AddClassModuleComment

#add_comment

Constructor Details

#initialize(name, superclass) ⇒ PuppetClass

Returns a new instance of PuppetClass.



101
102
103
104
105
106
107
# File 'lib/puppet/util/rdoc/code_objects.rb', line 101

def initialize(name, superclass)
  super(name,superclass)
  @resource_list = []
  @requires = []
  @realizes = []
  @childs = []
end

Instance Attribute Details

#childsObject

Returns the value of attribute childs.



99
100
101
# File 'lib/puppet/util/rdoc/code_objects.rb', line 99

def childs
  @childs
end

#realizesObject

Returns the value of attribute realizes.



99
100
101
# File 'lib/puppet/util/rdoc/code_objects.rb', line 99

def realizes
  @realizes
end

#requiresObject

Returns the value of attribute requires.



99
100
101
# File 'lib/puppet/util/rdoc/code_objects.rb', line 99

def requires
  @requires
end

#resource_listObject

Returns the value of attribute resource_list.



99
100
101
# File 'lib/puppet/util/rdoc/code_objects.rb', line 99

def resource_list
  @resource_list
end

Instance Method Details

#add_child(child) ⇒ Object



136
137
138
# File 'lib/puppet/util/rdoc/code_objects.rb', line 136

def add_child(child)
  @childs << child
end

#add_realize(realized) ⇒ Object



132
133
134
# File 'lib/puppet/util/rdoc/code_objects.rb', line 132

def add_realize(realized)
  add_to(@realizes, realized)
end

#add_require(required) ⇒ Object

we’re (ab)using the RDoc require system here. we’re adding a required Puppet class, overriding the RDoc add_require method which sees ruby required files.



128
129
130
# File 'lib/puppet/util/rdoc/code_objects.rb', line 128

def add_require(required)
  add_to(@requires, required)
end

#add_resource(resource) ⇒ Object



113
114
115
# File 'lib/puppet/util/rdoc/code_objects.rb', line 113

def add_resource(resource)
  add_to(@resource_list, resource)
end

#aref_prefixObject



109
110
111
# File 'lib/puppet/util/rdoc/code_objects.rb', line 109

def aref_prefix
  'puppet_class'
end

#find_symbol(symbol, method = nil) ⇒ Object

Look up the given symbol. RDoc only looks for class1::class2.method or class1::class2#method. Since our definitions are mapped to RDoc methods but are written class1::class2::define we need to perform the lookup by ourselves.



144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# File 'lib/puppet/util/rdoc/code_objects.rb', line 144

def find_symbol(symbol, method=nil)
  result = super(symbol)
  if not result and symbol =~ /::/
    modules = symbol.split(/::/)
    unless modules.empty?
      module_name = modules.shift
      result = find_module_named(module_name)
      if result
        last_name = ""
        previous = nil
        modules.each do |mod|
          previous = result
          last_name = mod
          result = result.find_module_named(mod)
          break unless result
        end
        unless result
          result = previous
          method = last_name
        end
      end
    end
    if result && method
      if !result.respond_to?(:find_local_symbol)
        p result.name
        p method
        fail
      end
      result = result.find_local_symbol(method)
    end
  end
  result
end

#is_module?Boolean

Returns:

  • (Boolean)


117
118
119
# File 'lib/puppet/util/rdoc/code_objects.rb', line 117

def is_module?
  false
end

#superclass=(superclass) ⇒ Object



121
122
123
# File 'lib/puppet/util/rdoc/code_objects.rb', line 121

def superclass=(superclass)
  @superclass = superclass
end