Module: Cellect::Server::API::Helpers
- Defined in:
- lib/cellect/server/api/helpers.rb
Instance Method Summary collapse
- #_param_to(param, conversion, default) ⇒ Object
- #param_to_float(param, default: nil) ⇒ Object
- #param_to_int(param, default: nil) ⇒ Object
- #selector_params ⇒ Object
- #update_params ⇒ Object
- #workflow ⇒ Object
Instance Method Details
#_param_to(param, conversion, default) ⇒ Object
33 34 35 36 |
# File 'lib/cellect/server/api/helpers.rb', line 33 def _param_to(param, conversion, default) val = params[param] && params[param].send(conversion) params[param] && val && val > 0 ? val : default end |
#param_to_float(param, default: nil) ⇒ Object
29 30 31 |
# File 'lib/cellect/server/api/helpers.rb', line 29 def param_to_float(param, default: nil) _param_to param, :to_f, default end |
#param_to_int(param, default: nil) ⇒ Object
25 26 27 |
# File 'lib/cellect/server/api/helpers.rb', line 25 def param_to_int(param, default: nil) _param_to param, :to_i, default end |
#selector_params ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/cellect/server/api/helpers.rb', line 9 def selector_params { limit: param_to_int(:limit, default: 5), user_id: param_to_int(:user_id), group_id: param_to_int(:group_id) } end |
#update_params ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/cellect/server/api/helpers.rb', line 17 def update_params { subject_id: param_to_int(:subject_id), group_id: param_to_int(:group_id), priority: param_to_float(:priority) } end |
#workflow ⇒ Object
5 6 7 |
# File 'lib/cellect/server/api/helpers.rb', line 5 def workflow @workflow ||= Workflow[params[:workflow_id]] end |