Module: Clickwrap::Registration::ClassMethods
- Defined in:
- lib/clickwrap/registration.rb
Overview
The optional Devise controller macro. Nothing happens unless a host calls it, and merely loading Clickwrap never requires Devise.
Instance Method Summary collapse
Instance Method Details
#clickwraps_registration_with(policy_key, **options) ⇒ Object
Devise:
class Users::RegistrationsController < Devise::RegistrationsController
clickwraps_registration_with :signup
end
Wraps the resource save so the account and its evidence share one
transaction. Devise's own create action remains the implementation of
the flow; Clickwrap decorates only the resource's one save call.
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/clickwrap/registration.rb', line 77 def clickwraps_registration_with(policy_key, **) after_save = .delete(:after_account_is_saved_inside_transaction) unless after_save.nil? || after_save.is_a?(Symbol) || after_save.is_a?(String) || after_save.respond_to?(:call) raise DefinitionError, "`after_account_is_saved_inside_transaction:` must name a controller method " \ "or be callable. It receives `account:` and `pending_receipt:`." end prepend Clickwrap::Registration::DeviseAdapter self.clickwrap_registration_policy = policy_key self. = self.clickwrap_after_registration_account_is_saved = after_save end |