Class: Upkeep::Rails::Configuration
- Inherits:
-
Object
- Object
- Upkeep::Rails::Configuration
- Defined in:
- lib/upkeep/rails/configuration.rb
Defined Under Namespace
Classes: IdentityBuilder, IdentityDefinition
Constant Summary collapse
- SUBSCRIPTION_STORES =
[:active_record, :memory].freeze
- REFUSED_BOUNDARY_BEHAVIORS =
[:raise, :warn].freeze
- IDENTITY_SOURCES =
[:current, :session, :cookie, :warden].freeze
- DELIVERY_ADAPTERS =
[:async, :active_job, :inline].freeze
Instance Attribute Summary collapse
-
#activation_token_expires_in ⇒ Object
Returns the value of attribute activation_token_expires_in.
-
#delivery_adapter ⇒ Object
Returns the value of attribute delivery_adapter.
-
#delivery_batch_window ⇒ Object
Returns the value of attribute delivery_batch_window.
-
#delivery_queue ⇒ Object
Returns the value of attribute delivery_queue.
-
#enabled ⇒ Object
Returns the value of attribute enabled.
-
#subscription_store ⇒ Object
Returns the value of attribute subscription_store.
Instance Method Summary collapse
- #clear_identities! ⇒ Object
- #identify(name, current: nil, session: nil, cookie: nil, warden: nil, &block) ⇒ Object
- #identity_definition(name) ⇒ Object
- #identity_definitions ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #refused_boundary_behavior ⇒ Object
- #refused_boundary_behavior=(value) ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
76 77 78 79 80 81 82 83 84 85 |
# File 'lib/upkeep/rails/configuration.rb', line 76 def initialize @enabled = true @subscription_store = :active_record @delivery_adapter = :async @delivery_queue = :upkeep_realtime @delivery_batch_window = 0.01 @refused_boundary_behavior = nil @activation_token_expires_in = 24 * 60 * 60 @identity_definitions = {} end |
Instance Attribute Details
#activation_token_expires_in ⇒ Object
Returns the value of attribute activation_token_expires_in.
70 71 72 |
# File 'lib/upkeep/rails/configuration.rb', line 70 def activation_token_expires_in @activation_token_expires_in end |
#delivery_adapter ⇒ Object
Returns the value of attribute delivery_adapter.
74 75 76 |
# File 'lib/upkeep/rails/configuration.rb', line 74 def delivery_adapter @delivery_adapter end |
#delivery_batch_window ⇒ Object
Returns the value of attribute delivery_batch_window.
71 72 73 |
# File 'lib/upkeep/rails/configuration.rb', line 71 def delivery_batch_window @delivery_batch_window end |
#delivery_queue ⇒ Object
Returns the value of attribute delivery_queue.
72 73 74 |
# File 'lib/upkeep/rails/configuration.rb', line 72 def delivery_queue @delivery_queue end |
#enabled ⇒ Object
Returns the value of attribute enabled.
69 70 71 |
# File 'lib/upkeep/rails/configuration.rb', line 69 def enabled @enabled end |
#subscription_store ⇒ Object
Returns the value of attribute subscription_store.
73 74 75 |
# File 'lib/upkeep/rails/configuration.rb', line 73 def subscription_store @subscription_store end |
Instance Method Details
#clear_identities! ⇒ Object
151 152 153 |
# File 'lib/upkeep/rails/configuration.rb', line 151 def clear_identities! @identity_definitions.clear end |
#identify(name, current: nil, session: nil, cookie: nil, warden: nil, &block) ⇒ Object
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/upkeep/rails/configuration.rb', line 124 def identify(name, current: nil, session: nil, cookie: nil, warden: nil, &block) source, source_key = identity_source(current: current, session: session, cookie: , warden: warden) builder = IdentityBuilder.new if block block.arity == 1 ? block.call(builder) : builder.instance_eval(&block) end unless builder.subscribe_block raise ConfigurationError, "config.identify :#{name} requires a subscribe block" end @identity_definitions[name.to_sym] = IdentityDefinition.new( name: name, source: source, source_key: source_key, subscribe_block: builder.subscribe_block ) end |
#identity_definition(name) ⇒ Object
147 148 149 |
# File 'lib/upkeep/rails/configuration.rb', line 147 def identity_definition(name) @identity_definitions.fetch(name.to_sym) end |
#identity_definitions ⇒ Object
143 144 145 |
# File 'lib/upkeep/rails/configuration.rb', line 143 def identity_definitions @identity_definitions.values end |
#refused_boundary_behavior ⇒ Object
109 110 111 |
# File 'lib/upkeep/rails/configuration.rb', line 109 def refused_boundary_behavior @refused_boundary_behavior || default_refused_boundary_behavior end |
#refused_boundary_behavior=(value) ⇒ Object
113 114 115 116 117 118 119 120 121 122 |
# File 'lib/upkeep/rails/configuration.rb', line 113 def refused_boundary_behavior=(value) value = value.to_sym if value.respond_to?(:to_sym) unless REFUSED_BOUNDARY_BEHAVIORS.include?(value) raise ConfigurationError, "Unknown Upkeep refused_boundary_behavior #{value.inspect}; expected one of #{REFUSED_BOUNDARY_BEHAVIORS.join(", ")}" end @refused_boundary_behavior = value end |