Module: Moist::Action
- Includes:
- Fear::Either::Mixin
- Defined in:
- lib/moist/action.rb,
lib/moist/action/version.rb
Overview
This module provides validation logic for controller actions.
Defined Under Namespace
Modules: Params
Constant Summary collapse
- VERSION =
'0.2.0'.freeze
Class Method Summary collapse
Instance Method Summary collapse
-
#call(params) ⇒ Fear::Right<any>, Fear::Left<{Symbol => <String>}>
Returns
Fear::Rightin case of successful validation orFear::Leftin case of error. -
#perform(_params) ⇒ <any>
Template method to be overridden by an Action.
Class Method Details
.included(base) ⇒ Object
48 49 50 |
# File 'lib/moist/action.rb', line 48 def included(base) base.extend(Params) end |
Instance Method Details
#call(params) ⇒ Fear::Right<any>, Fear::Left<{Symbol => <String>}>
Returns Fear::Right in case of successful validation or Fear::Left in case of error.
57 58 59 60 61 62 63 64 |
# File 'lib/moist/action.rb', line 57 def call(params) validation_result = self.class.params.(params) if validation_result.success? Right(perform(validation_result.output)) else Left(validation_result.) end end |
#perform(_params) ⇒ <any>
Template method to be overridden by an Action
69 70 71 |
# File 'lib/moist/action.rb', line 69 def perform(_params) raise NotImplementedError end |