Module: Vet360::Writeable

Extended by:
ActiveSupport::Concern
Included in:
V0::Profile::AddressesController, V0::Profile::EmailAddressesController, V0::Profile::PermissionsController, V0::Profile::TelephonesController, V0::Profile::TransactionsController
Defined in:
app/controllers/concerns/vet360/writeable.rb

Instance Method Summary collapse

Instance Method Details

#invalidate_cacheObject



28
29
30
# File 'app/controllers/concerns/vet360/writeable.rb', line 28

def invalidate_cache
  VAProfileRedis::Cache.invalidate(@current_user)
end

#write_to_vet360_and_render_transaction!(type, params, http_verb: 'post') ⇒ Response

For the passed VAProfile model type and params, it:

- builds and validates a VAProfile models
- POSTs/PUTs the model data to VAProfile
- creates a new AsyncTransaction db record, based on the type
- renders the transaction through the base serializer

Parameters:

  • type (String)

    the VAProfile::Models type (i.e. ‘Email’, ‘Address’, etc.)

  • params (ActionController::Parameters)

    The strong params from the controller

  • http_verb (String) (defaults to: 'post')

    The type of write request being made to VAProfile (‘post’ or ‘put’)

Returns:

  • (Response)

    Normal controller ‘render json:` response with a response.body, .status, etc.



21
22
23
24
25
26
# File 'app/controllers/concerns/vet360/writeable.rb', line 21

def write_to_vet360_and_render_transaction!(type, params, http_verb: 'post')
  record = build_record(type, params)
  validate!(record)
  response = write_valid_record!(http_verb, type, record)
  render_new_transaction!(type, response)
end