Module: Audiences

Defined in:
lib/audiences.rb,
lib/audiences/engine.rb,
lib/audiences/version.rb,
lib/audiences/scim_proxy.rb,
app/models/audiences/context.rb,
app/jobs/audiences/application_job.rb,
app/models/audiences/application_record.rb,
app/controllers/audiences/contexts_controller.rb,
app/controllers/audiences/scim_proxy_controller.rb,
app/controllers/audiences/application_controller.rb

Overview

Audiences system Audiences pushes notifications to your rails app when a SCIM backend updates a user, notifying matching audiences.

Defined Under Namespace

Modules: ScimProxy Classes: ApplicationController, ApplicationJob, ApplicationRecord, Context, ContextsController, Engine, ScimProxyController

Constant Summary collapse

GID_RESOURCE =
"audiences"
VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.load(key) ⇒ Object

Loads a context for the given context key

Parameters:

  • token (String)

    a signed token (see #sign)

Returns:

  • Audience::Context



29
30
31
32
# File 'lib/audiences.rb', line 29

def load(key)
  owner = GlobalID::Locator.locate_signed(key, for: GID_RESOURCE)
  ::Audiences::Context.where(owner: owner).first_or_create!.tap(&:readonly!)
end

.sign(owner) ⇒ String

Provides a key to load an audience context for the given owner. An owner should implment GlobalID::Identification.

Parameters:

  • owner (GlobalID::Identification)

    an owning model

Returns:

  • (String)

    context key



20
21
22
# File 'lib/audiences.rb', line 20

def sign(owner)
  owner.to_sgid(for: GID_RESOURCE)
end