Class: Cuprum::Rails::Action

Inherits:
Command
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/cuprum/rails/action.rb

Overview

Abstract command that implement a controller action.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#optionsHash<Symbol, Object> (readonly)

Returns additional options for the action.

Returns:

  • (Hash<Symbol, Object>)

    additional options for the action.



32
33
34
# File 'lib/cuprum/rails/action.rb', line 32

def options
  @options
end

#repositoryCuprum::Collections::Repository (readonly)

Returns the repository containing the data collections for the application or scope.

Returns:

  • (Cuprum::Collections::Repository)

    the repository containing the data collections for the application or scope.



36
37
38
# File 'lib/cuprum/rails/action.rb', line 36

def repository
  @repository
end

#requestCuprum::Rails::Request (readonly)

Returns the formatted request.

Returns:



39
40
41
# File 'lib/cuprum/rails/action.rb', line 39

def request
  @request
end

Instance Method Details

#call(request: , repository: nil, **options) ⇒ Cuprum::Result

Performs the controller action.

Subclasses should implement a #process method with the :request keyword, which accepts an ActionDispatch::Request instance.

Parameters:

  • request (ActionDispatch::Request) (defaults to: )

    the Rails request.

  • repository (Cuprum::Collections::Repository) (defaults to: nil)

    the repository containing the data collections for the application or scope.

  • options (Hash<Symbol, Object>)

    additional options for the action.

Returns:

  • (Cuprum::Result)

    the result of the action.



# File 'lib/cuprum/rails/action.rb', line 14

#paramsHash<String, Object>

Returns the request parameters.

Returns:

  • (Hash<String, Object>)

    the request parameters.



29
# File 'lib/cuprum/rails/action.rb', line 29

def_delegators :@request, :params