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.



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

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

Instance Attribute Details

#childsObject

Returns the value of attribute childs.



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

def childs
  @childs
end

#realizesObject

Returns the value of attribute realizes.



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

def realizes
  @realizes
end

#requiresObject

Returns the value of attribute requires.



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

def requires
  @requires
end

#resource_listObject

Returns the value of attribute resource_list.



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

def resource_list
  @resource_list
end

Instance Method Details

#add_child(child) ⇒ Object



140
141
142
# File 'lib/puppet/util/rdoc/code_objects.rb', line 140

def add_child(child)
  @childs << child
end

#add_realize(realized) ⇒ Object



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

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.



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

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

#add_resource(resource) ⇒ Object



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

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

#aref_prefixObject



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

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.



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
177
178
179
180
# File 'lib/puppet/util/rdoc/code_objects.rb', line 148

def find_symbol(symbol, method = nil)
  result = super(symbol)
  if !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
      unless 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)


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

def is_module?
  false
end

#superclass=(superclass) ⇒ Object



125
126
127
# File 'lib/puppet/util/rdoc/code_objects.rb', line 125

def superclass=(superclass)
  @superclass = superclass
end