Class: UseCase
- Inherits:
-
Object
- Object
- UseCase
- Defined in:
- lib/keight/skeleton/app/model.rb
Overview
Usecase class in order to separate business logics from framework.
Instance Method Summary collapse
-
#initialize(db, login_user = nil) ⇒ UseCase
constructor
A new instance of UseCase.
- #run(params, *urlpath_params) ⇒ Object
Constructor Details
#initialize(db, login_user = nil) ⇒ UseCase
Returns a new instance of UseCase.
104 105 106 107 |
# File 'lib/keight/skeleton/app/model.rb', line 104 def initialize(db, login_user=nil) @db = db @login_user = login_user end |
Instance Method Details
#run(params, *urlpath_params) ⇒ Object
109 110 111 112 113 114 115 116 117 |
# File 'lib/keight/skeleton/app/model.rb', line 109 def run(params, *urlpath_params) errors = validate(params) return nil, errors if errors args = accommodate(params, *urlpath_params) model, error = execute(*args) return nil, error if error content = represent(model) return content, nil end |