Class: CentralAgent::SaveBoatService
- Inherits:
-
Object
- Object
- CentralAgent::SaveBoatService
- Defined in:
- app/services/central_agent/save_boat_service.rb
Instance Attribute Summary collapse
-
#boat ⇒ Object
readonly
Returns the value of attribute boat.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Instance Method Summary collapse
-
#initialize ⇒ SaveBoatService
constructor
A new instance of SaveBoatService.
- #perform(boat_params, cookies, current_user, state: Boat::STATE_PREMODERATED) ⇒ Object
Constructor Details
#initialize ⇒ SaveBoatService
Returns a new instance of SaveBoatService.
6 7 8 |
# File 'app/services/central_agent/save_boat_service.rb', line 6 def initialize _reset_ivars end |
Instance Attribute Details
#boat ⇒ Object (readonly)
Returns the value of attribute boat.
4 5 6 |
# File 'app/services/central_agent/save_boat_service.rb', line 4 def boat @boat end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
4 5 6 |
# File 'app/services/central_agent/save_boat_service.rb', line 4 def errors @errors end |
Instance Method Details
#perform(boat_params, cookies, current_user, state: Boat::STATE_PREMODERATED) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/services/central_agent/save_boat_service.rb', line 13 def perform(boat_params, , current_user, state: Boat::STATE_PREMODERATED) _reset_ivars @schema = ::Schemas::CentralAgent::SaveBoatSchema.new boat_params.dup # проверяем параметры, пришедшие с формы unless @schema.valid? @errors = @schema.errors. return false end if boat_params[:id].present? boat = _update_boat(@schema.attributes, ) else boat = _create_boat(@schema.attributes, , current_user, state) end @boat = boat true end |