Class: Wallaby::ModelServiceProvider
- Inherits:
-
Object
- Object
- Wallaby::ModelServiceProvider
- Defined in:
- lib/interfaces/wallaby/model_service_provider.rb
Overview
Model service provider interface
Direct Known Subclasses
Instance Method Summary collapse
-
#collection(_params, _authorizer) ⇒ #to_a
Fetch collection by params.
-
#create(_resource, _params, _authorizer) ⇒ Object
Save the newly initialized resource.
-
#destroy(_resource, _params, _authorizer) ⇒ Object
Destroy the given resource.
-
#find(_id, _params, _authorizer) ⇒ Object
Find a resource using id.
-
#initialize(model_class, model_decorator) ⇒ ModelServiceProvider
constructor
A new instance of ModelServiceProvider.
-
#new(_params, _authorizer) ⇒ Object
Initialize the model class using params.
-
#paginate(_query, _params) ⇒ #to_a
Paginate the resources.
-
#permit(_params, _action, _authorizer) ⇒ ActionController::Parameters
To allowlist params for a model class.
-
#update(_resource, _params, _authorizer) ⇒ Object
Update the persisted resource.
Constructor Details
#initialize(model_class, model_decorator) ⇒ ModelServiceProvider
Returns a new instance of ModelServiceProvider.
8 9 10 11 12 13 |
# File 'lib/interfaces/wallaby/model_service_provider.rb', line 8 def initialize(model_class, model_decorator) raise ::ArgumentError, 'model class required' unless model_class @model_class = model_class @model_decorator = model_decorator end |
Instance Method Details
#collection(_params, _authorizer) ⇒ #to_a
Fetch collection by params
28 29 30 |
# File 'lib/interfaces/wallaby/model_service_provider.rb', line 28 def collection(_params, ) raise NotImplemented end |
#create(_resource, _params, _authorizer) ⇒ Object
Save the newly initialized resource
62 63 64 |
# File 'lib/interfaces/wallaby/model_service_provider.rb', line 62 def create(_resource, _params, ) raise NotImplemented end |
#destroy(_resource, _params, _authorizer) ⇒ Object
Destroy the given resource
80 81 82 |
# File 'lib/interfaces/wallaby/model_service_provider.rb', line 80 def destroy(_resource, _params, ) raise NotImplemented end |
#find(_id, _params, _authorizer) ⇒ Object
Find a resource using id
53 54 55 |
# File 'lib/interfaces/wallaby/model_service_provider.rb', line 53 def find(_id, _params, ) raise NotImplemented end |
#new(_params, _authorizer) ⇒ Object
Initialize the model class using params
44 45 46 |
# File 'lib/interfaces/wallaby/model_service_provider.rb', line 44 def new(_params, ) raise NotImplemented end |
#paginate(_query, _params) ⇒ #to_a
Paginate the resources
36 37 38 |
# File 'lib/interfaces/wallaby/model_service_provider.rb', line 36 def paginate(_query, _params) raise NotImplemented end |
#permit(_params, _action, _authorizer) ⇒ ActionController::Parameters
To allowlist params for a model class
20 21 22 |
# File 'lib/interfaces/wallaby/model_service_provider.rb', line 20 def permit(_params, _action, ) raise NotImplemented end |
#update(_resource, _params, _authorizer) ⇒ Object
Update the persisted resource
71 72 73 |
# File 'lib/interfaces/wallaby/model_service_provider.rb', line 71 def update(_resource, _params, ) raise NotImplemented end |