Class: HaveAPI::Resources::ActionState::Cancel
- Defined in:
- lib/haveapi/resources/action_state.rb
Constant Summary
Constants inherited from Action
Instance Attribute Summary collapse
-
#state_id ⇒ Object
readonly
Returns the value of attribute state_id.
Attributes inherited from Action
#current_user, #errors, #flags, #message, #request, #version
Instance Method Summary collapse
Methods inherited from Action
add_pre_authorize_blocks, authorize, #authorized?, build_route, delayed_inherited, describe, example, from_context, inherit_attrs_from_resource, inherited, initialize, #initialize, input, #input, meta, #meta, model_adapter, output, parameter_metadata_i18n_items, path_param_names, path_params, #path_params, #pre_exec, #prepare, resolve_path_params, #safe_exec, #safe_output, #set_meta, #v?, #validate!, validate_build
Methods included from Hookable
Methods inherited from Common
check_build, has_attr, inherit_attrs
Constructor Details
This class inherits a constructor from HaveAPI::Action
Instance Attribute Details
#state_id ⇒ Object (readonly)
Returns the value of attribute state_id.
212 213 214 |
# File 'lib/haveapi/resources/action_state.rb', line 212 def state_id @state_id end |
Instance Method Details
#exec ⇒ Object
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
# File 'lib/haveapi/resources/action_state.rb', line 189 def exec state = @context.server.action_state.new( current_user, id: path_params['action_state_id'] ) error!(HaveAPI.('haveapi.action_state.not_found')) unless state.valid? ret = state.cancel if ret.is_a?(::Numeric) @state_id = ret elsif ret ok! else error!(HaveAPI.('haveapi.action_state.cancellation_failed')) end rescue RuntimeError, NotImplementedError => e error!(e.) end |