Class: Dox::DSL::Action

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from AttrProxy

#method_missing

Constructor Details

#initialize(name, &block) ⇒ Action

Returns a new instance of Action.



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

def initialize(name, &block)
  self.name = name
  instance_eval(&block) if block_given?

  raise(Dox::Errors::InvalidActionError, 'Action name is required!') if @name.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.



9
10
11
# File 'lib/dox/dsl/action.rb', line 9

def desc=(value)
  @desc = 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/action.rb', line 6

def name=(value)
  @name = value
end

#params=(value) ⇒ Object (writeonly)

Sets the attribute params

Parameters:

  • value

    the value to set the attribute params to.



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

def params=(value)
  @params = value
end

#path=(value) ⇒ Object (writeonly)

Sets the attribute path

Parameters:

  • value

    the value to set the attribute path to.



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

def path=(value)
  @path = value
end

#verb=(value) ⇒ Object (writeonly)

Sets the attribute verb

Parameters:

  • value

    the value to set the attribute verb to.



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

def verb=(value)
  @verb = value
end

Instance Method Details

#configObject



19
20
21
22
23
24
25
26
27
# File 'lib/dox/dsl/action.rb', line 19

def config
  {
    action_name: @name.presence,
    action_verb: @verb.presence,
    action_path: @path.presence,
    action_desc: @desc.presence,
    action_params: @params.presence
  }
end