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 = nil) ⇒ 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) ⇒ ActionController::Parameters
To whitelist params for a model class.
-
#update(_resource, _params, _authorizer) ⇒ Object
Update the persisted resource.
Constructor Details
#initialize(model_class, model_decorator = nil) ⇒ ModelServiceProvider
Returns a new instance of ModelServiceProvider.
6 7 8 9 10 |
# File 'lib/interfaces/wallaby/model_service_provider.rb', line 6 def initialize(model_class, model_decorator = nil) raise ::ArgumentError, 'model class required' unless model_class @model_class = model_class @model_decorator = model_decorator || Map.model_decorator_map(model_class) end |
Instance Method Details
#collection(_params, _authorizer) ⇒ #to_a
Fetch collection by params
23 24 25 |
# File 'lib/interfaces/wallaby/model_service_provider.rb', line 23 def collection(_params, ) raise NotImplemented end |
#create(_resource, _params, _authorizer) ⇒ Object
Save the newly initialized resource
57 58 59 |
# File 'lib/interfaces/wallaby/model_service_provider.rb', line 57 def create(_resource, _params, ) raise NotImplemented end |
#destroy(_resource, _params, _authorizer) ⇒ Object
Destroy the given resource
75 76 77 |
# File 'lib/interfaces/wallaby/model_service_provider.rb', line 75 def destroy(_resource, _params, ) raise NotImplemented end |
#find(_id, _params, _authorizer) ⇒ Object
Find a resource using id
48 49 50 |
# File 'lib/interfaces/wallaby/model_service_provider.rb', line 48 def find(_id, _params, ) raise NotImplemented end |
#new(_params, _authorizer) ⇒ Object
Initialize the model class using params
39 40 41 |
# File 'lib/interfaces/wallaby/model_service_provider.rb', line 39 def new(_params, ) raise NotImplemented end |
#paginate(_query, _params) ⇒ #to_a
Paginate the resources
31 32 33 |
# File 'lib/interfaces/wallaby/model_service_provider.rb', line 31 def paginate(_query, _params) raise NotImplemented end |
#permit(_params) ⇒ ActionController::Parameters
To whitelist params for a model class
15 16 17 |
# File 'lib/interfaces/wallaby/model_service_provider.rb', line 15 def permit(_params) raise NotImplemented end |
#update(_resource, _params, _authorizer) ⇒ Object
Update the persisted resource
66 67 68 |
# File 'lib/interfaces/wallaby/model_service_provider.rb', line 66 def update(_resource, _params, ) raise NotImplemented end |