Class: Pinnable::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/pinnable/configuration.rb

Overview

The single seam between the engine and its host. Defaults are safe-off: with no configuration the widget never renders and every endpoint 404s, so a host opts in deliberately rather than by accident.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/pinnable/configuration.rb', line 9

def initialize
  @enabled_for       = ->(_user) { false }                 # the gate
  @current_user      = ->(_controller) { nil }             # host's auth
  @tenant_scope      = ->(_controller) { nil }             # optional multitenancy
  @user_label        = ->(user) { user.try(:email) || user.try(:name) || user.to_s }
  @resolver_label    = @user_label
  @parent_controller = "ActionController::Base"            # inherit host auth/CSRF/layout
  @encrypt           = false                               # opt-in AR encryption of body/anchor
  @audit             = ->(_pin, _event, _by) {}            # optional sink
  @anchor_max_bytes  = 50_000
  @layout            = "pinnable/application"          # host sets its own for native chrome
end

Instance Attribute Details

#anchor_max_bytesObject

Returns the value of attribute anchor_max_bytes.



6
7
8
# File 'lib/pinnable/configuration.rb', line 6

def anchor_max_bytes
  @anchor_max_bytes
end

#auditObject

Returns the value of attribute audit.



6
7
8
# File 'lib/pinnable/configuration.rb', line 6

def audit
  @audit
end

#current_userObject

Returns the value of attribute current_user.



6
7
8
# File 'lib/pinnable/configuration.rb', line 6

def current_user
  @current_user
end

#enabled_forObject

Returns the value of attribute enabled_for.



6
7
8
# File 'lib/pinnable/configuration.rb', line 6

def enabled_for
  @enabled_for
end

#encryptObject

Returns the value of attribute encrypt.



6
7
8
# File 'lib/pinnable/configuration.rb', line 6

def encrypt
  @encrypt
end

#layoutObject

Returns the value of attribute layout.



6
7
8
# File 'lib/pinnable/configuration.rb', line 6

def layout
  @layout
end

#parent_controllerObject

Returns the value of attribute parent_controller.



6
7
8
# File 'lib/pinnable/configuration.rb', line 6

def parent_controller
  @parent_controller
end

#resolver_labelObject

Returns the value of attribute resolver_label.



6
7
8
# File 'lib/pinnable/configuration.rb', line 6

def resolver_label
  @resolver_label
end

#tenant_scopeObject

Returns the value of attribute tenant_scope.



6
7
8
# File 'lib/pinnable/configuration.rb', line 6

def tenant_scope
  @tenant_scope
end

#user_labelObject

Returns the value of attribute user_label.



6
7
8
# File 'lib/pinnable/configuration.rb', line 6

def user_label
  @user_label
end