Class: YARD::CodeObjects::Chef::ResourceObject

Inherits:
ChefObject
  • Object
show all
Defined in:
lib/yard-chef/code_objects/resource_object.rb

Overview

A ResourceObject represents a lightweight resource in chef. See docs.opscode.com/essentials_cookbook_lwrp.html

Instance Attribute Summary

Attributes inherited from ChefObject

#docstring_type

Instance Method Summary collapse

Methods inherited from ChefObject

#children_by_type, #cookbooks, register, register_element

Constructor Details

#initialize(namespace, name) ⇒ ResourceObject

Creates a new instance of ResourceObject.

resource belongs

Parameters:

  • namespace (NamespaceObject)

    namespace to which the lightweight

  • name (String)

    name of the lightweight resource



40
41
42
43
# File 'lib/yard-chef/code_objects/resource_object.rb', line 40

def initialize(namespace, name)
  super(namespace, name)
  @providers = []
end

Instance Method Details

#actionsArray<ActionObject>

Actions supported by the lightweight resource.

Returns:

  • (Array<ActionObject>)

    actions in the lightweight resource



75
76
77
# File 'lib/yard-chef/code_objects/resource_object.rb', line 75

def actions
  children_by_type(:action)
end

#attributesArray<AttributeObject>

Attributes defined in the lightweight resource.

Returns:



67
68
69
# File 'lib/yard-chef/code_objects/resource_object.rb', line 67

def attributes
  children_by_type(:attribute)
end

#long_nameString

Constructs class name for the lightweight resource.

Returns:

  • (String)

    class name for the lightweight resource



49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/yard-chef/code_objects/resource_object.rb', line 49

def long_name
  name = ''
  if @name.to_s =~ /_/
    @name.to_s.split('_').each do |str|
      name << str.to_s.capitalize
    end
  else
    name = @name.to_s.capitalize
  end

  namespace = @namespace.to_s.split('::').map(&:capitalize)
  "#{namespace.join('::')}::#{name}"
end