Class: Realm::ActionHandler
- Inherits:
-
Object
- Object
- Realm::ActionHandler
- Extended by:
- Mixins::ContextInjection::ClassMethods
- Includes:
- Mixins::AggregateMember, Mixins::RepositoryHelper
- Defined in:
- lib/realm/action_handler.rb,
lib/realm/action_handler/result.rb
Direct Known Subclasses
Defined Under Namespace
Classes: Result
Class Attribute Summary collapse
-
.contracts ⇒ Object
readonly
Returns the value of attribute contracts.
Class Method Summary collapse
Instance Method Summary collapse
- #call(action: :handle, params: {}) ⇒ Object
-
#initialize(runtime: nil) ⇒ ActionHandler
constructor
A new instance of ActionHandler.
Methods included from Mixins::ContextInjection::ClassMethods
Methods included from Mixins::RepositoryHelper
Methods included from Mixins::AggregateMember
Constructor Details
#initialize(runtime: nil) ⇒ ActionHandler
Returns a new instance of ActionHandler.
56 57 58 |
# File 'lib/realm/action_handler.rb', line 56 def initialize(runtime: nil) @runtime = runtime end |
Class Attribute Details
.contracts ⇒ Object (readonly)
Returns the value of attribute contracts.
18 19 20 |
# File 'lib/realm/action_handler.rb', line 18 def contracts @contracts end |
Class Method Details
.call(action: :handle, params: {}, runtime: nil) ⇒ Object
20 21 22 |
# File 'lib/realm/action_handler.rb', line 20 def call(action: :handle, params: {}, runtime: nil) new(runtime: runtime).(action: action, params: params) end |
Instance Method Details
#call(action: :handle, params: {}) ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/realm/action_handler.rb', line 60 def call(action: :handle, params: {}) # TODO: check permissions raise CannotHandleAction.new(self, action) unless respond_to?(action) safe_params = validate(action, params.to_h) send(action, **safe_params) end |