Class: Dox::DSL::Resource

Inherits:
Object
  • Object
show all
Includes:
AttrProxy
Defined in:
lib/dox/dsl/resource.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from AttrProxy

#method_missing

Constructor Details

#initialize(name, &block) ⇒ Resource

Returns a new instance of Resource.



12
13
14
15
16
17
18
19
# File 'lib/dox/dsl/resource.rb', line 12

def initialize(name, &block)
  self.name = name

  instance_eval(&block)

  raise(Dox::Errors::InvalidResourceError, 'Resource name is required!') if @name.blank?
  raise(Dox::Errors::InvalidResourceError, 'Resource group is required!') if @group.blank?
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Dox::DSL::AttrProxy

Instance Attribute Details

#desc=(value) ⇒ Object (writeonly)

Sets the attribute desc

Parameters:

  • value

    the value to set the attribute desc to.



10
11
12
# File 'lib/dox/dsl/resource.rb', line 10

def desc=(value)
  @desc = value
end

#endpoint=(value) ⇒ Object (writeonly)

Sets the attribute endpoint

Parameters:

  • value

    the value to set the attribute endpoint to.



8
9
10
# File 'lib/dox/dsl/resource.rb', line 8

def endpoint=(value)
  @endpoint = value
end

#group=(value) ⇒ Object (writeonly)

Sets the attribute group

Parameters:

  • value

    the value to set the attribute group to.



7
8
9
# File 'lib/dox/dsl/resource.rb', line 7

def group=(value)
  @group = value
end

#name=(value) ⇒ Object (writeonly)

Sets the attribute name

Parameters:

  • value

    the value to set the attribute name to.



6
7
8
# File 'lib/dox/dsl/resource.rb', line 6

def name=(value)
  @name = value
end

Instance Method Details

#configObject



21
22
23
24
25
26
27
28
# File 'lib/dox/dsl/resource.rb', line 21

def config
  {
    resource_name: @name.presence,
    resource_desc: @desc.presence,
    resource_group_name: @group.presence,
    apidoc: true
  }
end