Class: HaveAPI::Resources::ActionState::Cancel
- Defined in:
- lib/haveapi/resources/action_state.rb
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, #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.
184 185 186 |
# File 'lib/haveapi/resources/action_state.rb', line 184 def state_id @state_id end |
Instance Method Details
#exec ⇒ Object
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
# File 'lib/haveapi/resources/action_state.rb', line 161 def exec state = @context.server.action_state.new( current_user, id: params[:action_state_id] ) error!('action state not found') unless state.valid? ret = state.cancel if ret.is_a?(::Numeric) @state_id = ret elsif ret ok! else error!('cancellation failed') end rescue RuntimeError, NotImplementedError => e error!(e.) end |