Class: Uncouple::Action
- Inherits:
-
Object
- Object
- Uncouple::Action
- Includes:
- Authorization
- Defined in:
- lib/uncouple/action.rb,
lib/uncouple/action/authorization.rb,
lib/uncouple/action/instrumentation.rb
Defined Under Namespace
Modules: Authorization, Instrumentation
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Instance Method Summary collapse
- #failure? ⇒ Boolean
-
#initialize(params = nil) ⇒ Action
constructor
A new instance of Action.
- #perform ⇒ Object
- #perform?(&block) ⇒ Boolean
- #success? ⇒ Boolean
Methods included from Authorization
#authorize!, #current_user, #perform_with_authorization
Constructor Details
#initialize(params = nil) ⇒ Action
Returns a new instance of Action.
10 11 12 |
# File 'lib/uncouple/action.rb', line 10 def initialize(params=nil) @params = recast_parameters(params || {}) end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
8 9 10 |
# File 'lib/uncouple/action.rb', line 8 def params @params end |
Instance Method Details
#failure? ⇒ Boolean
22 23 24 |
# File 'lib/uncouple/action.rb', line 22 def failure? !success? end |
#perform ⇒ Object
14 15 16 |
# File 'lib/uncouple/action.rb', line 14 def perform raise NotImplementedError, "Overwrite `perform` in your action. Params: #{params}" end |
#perform?(&block) ⇒ Boolean
26 27 28 29 30 |
# File 'lib/uncouple/action.rb', line 26 def perform?(&block) perform block.call(self) if block_given? success? end |
#success? ⇒ Boolean
18 19 20 |
# File 'lib/uncouple/action.rb', line 18 def success? @success end |