Class: Decidim::Verifications::WorkflowManifest

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model
Defined in:
lib/decidim/verifications/workflow_manifest.rb

Overview

This class serves as a DSL to declaratively specify a verification method.

To define a direct verification method, you need to specify the ‘form` attribute as a `Rectify::Form` that will be valid if the authorization is valid.

To define a deferred verification method, you need specify the ‘engine` attribute as a full `Rails::Engine` (and optionally another engine for the admin side as the `admin_engine` attribute). The verification will succeed once the engine creates a valid authorization for the method with the `granted_at` column set in DB.

Note that whereas direct methods can be used for “on the fly” verification, deferred methods require the authorization status to be persisted into DB. That’s the reason why only direct methods can be used for user impersonation, for example, since they require continuous “on the fly” verification by the impersonating user.

Instance Method Summary collapse

Instance Method Details

#action_authorizer_classObject



59
60
61
62
63
64
65
# File 'lib/decidim/verifications/workflow_manifest.rb', line 59

def action_authorizer_class
  if @action_authorizer.present?
    @action_authorizer.constantize
  else
    DefaultActionAuthorizer
  end
end

#descriptionObject



55
56
57
# File 'lib/decidim/verifications/workflow_manifest.rb', line 55

def description
  "#{fullname} (#{I18n.t(type, scope: "decidim.authorization_handlers")})"
end

#engine_or_formObject



41
42
43
# File 'lib/decidim/verifications/workflow_manifest.rb', line 41

def engine_or_form
  engine || form
end

#fullnameObject



51
52
53
# File 'lib/decidim/verifications/workflow_manifest.rb', line 51

def fullname
  I18n.t("#{key}.name", scope: "decidim.authorization_handlers", default: name.humanize)
end

#typeObject



45
46
47
# File 'lib/decidim/verifications/workflow_manifest.rb', line 45

def type
  form ? "direct" : "multistep"
end