Class: Gruf::Commander::Request

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
lib/gruf/commander/request.rb

Overview

Base request class

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command:) ⇒ Request

Returns a new instance of Request.

Parameters:



32
33
34
# File 'lib/gruf/commander/request.rb', line 32

def initialize(command:)
  @command = command
end

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



27
28
29
# File 'lib/gruf/commander/request.rb', line 27

def command
  @command
end

Instance Method Details

#submit!Object

Validate and submit the request

rubocop:disable Style/RaiseArgs

Raises:



41
42
43
44
45
# File 'lib/gruf/commander/request.rb', line 41

def submit!
  raise InvalidRequest.new(self) unless valid?

  command.call(self)
end