Module: ChartMogul::Concerns::ToggleDisabled
- Included in:
- Invoice, LineItem, Transaction
- Defined in:
- lib/chartmogul/concerns/toggle_disabled.rb
Overview
Shared toggle_disabled! instance method for resources that support disabling. Expects the including class to have a ‘uuid` attribute.
Instance Method Summary collapse
-
#toggle_disabled!(disabled:, handle_as_user_edit: nil) ⇒ self
Toggle the disabled state of the resource.
Instance Method Details
#toggle_disabled!(disabled:, handle_as_user_edit: nil) ⇒ self
Toggle the disabled state of the resource
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/chartmogul/concerns/toggle_disabled.rb', line 12 def toggle_disabled!(disabled:, handle_as_user_edit: nil) path = "#{resource_path.path}/#{uuid}/disabled_state" path = self.class.build_query_path(path, handle_as_user_edit: handle_as_user_edit) resp = handling_errors do self.class.json_patch(path, { disabled: disabled }) end json = ChartMogul::Utils::JSONParser.parse(resp.body, immutable_keys: self.class.immutable_keys) assign_all_attributes(json) self end |