Module: Signoff

Extended by:
ActiveSupport::Concern
Includes:
Model
Defined in:
lib/signoff.rb,
lib/signoff/dsl.rb,
lib/signoff/model.rb,
lib/signoff/engine.rb,
lib/signoff/errors.rb,
lib/signoff/current.rb,
lib/signoff/version.rb,
lib/signoff/controller.rb,
lib/signoff/definition.rb,
app/models/signoff/event.rb,
lib/signoff/configuration.rb,
lib/generators/signoff/model/model_generator.rb,
lib/generators/signoff/install/install_generator.rb

Overview

Signoff adds concurrency-safe approval workflows with an immutable audit trail to ActiveRecord models.

class ExpenseReport < ApplicationRecord
include Signoff

signoff do
  state :draft
  state :manager_review
  state :approved
  state :rejected

  transition :draft,          to: :manager_review
  transition :manager_review, to: :approved

  reject_to :rejected
end
end

Including the module mixes in Signoff::Model (the signoff macro, transition methods, scopes and audit helpers). The same namespace also holds the configuration, the audit Event model and the supporting classes.

Defined Under Namespace

Modules: Controller, Generators, Model Classes: Configuration, Current, DSL, Definition, DefinitionError, Engine, Error, Event, InvalidTransitionError, MissingColumnError, NotConfiguredError, UnauthorizedError

Constant Summary collapse

VERSION =
"0.2.0"

Class Method Summary collapse

Class Method Details

.configurationObject Also known as: config

The current global configuration.



45
46
47
# File 'lib/signoff.rb', line 45

def configuration
  @configuration ||= Configuration.new
end

.configure {|configuration| ... } ⇒ Object

Configure the gem, typically from an initializer:

Signoff.configure do |config|
config.user_class         = "User"
config.track_ip_addresses = true
end

Yields:



56
57
58
# File 'lib/signoff.rb', line 56

def configure
  yield(configuration)
end

.reset_configuration!Object

Reset configuration to defaults (primarily useful in tests).



61
62
63
# File 'lib/signoff.rb', line 61

def reset_configuration!
  @configuration = Configuration.new
end