Class: Upkeep::Rails::Configuration::IdentityDefinition
- Inherits:
-
Object
- Object
- Upkeep::Rails::Configuration::IdentityDefinition
- Defined in:
- lib/upkeep/rails/configuration.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#source_key ⇒ Object
readonly
Returns the value of attribute source_key.
-
#subscribe_block ⇒ Object
readonly
Returns the value of attribute subscribe_block.
Instance Method Summary collapse
-
#initialize(name:, source:, source_key:, subscribe_block:) ⇒ IdentityDefinition
constructor
A new instance of IdentityDefinition.
- #matches_dependency?(dependency) ⇒ Boolean
- #source_label ⇒ Object
Constructor Details
#initialize(name:, source:, source_key:, subscribe_block:) ⇒ IdentityDefinition
Returns a new instance of IdentityDefinition.
16 17 18 19 20 21 |
# File 'lib/upkeep/rails/configuration.rb', line 16 def initialize(name:, source:, source_key:, subscribe_block:) @name = name.to_sym @source = source.to_sym @source_key = source_key @subscribe_block = subscribe_block end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
14 15 16 |
# File 'lib/upkeep/rails/configuration.rb', line 14 def name @name end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
14 15 16 |
# File 'lib/upkeep/rails/configuration.rb', line 14 def source @source end |
#source_key ⇒ Object (readonly)
Returns the value of attribute source_key.
14 15 16 |
# File 'lib/upkeep/rails/configuration.rb', line 14 def source_key @source_key end |
#subscribe_block ⇒ Object (readonly)
Returns the value of attribute subscribe_block.
14 15 16 |
# File 'lib/upkeep/rails/configuration.rb', line 14 def subscribe_block @subscribe_block end |
Instance Method Details
#matches_dependency?(dependency) ⇒ Boolean
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/upkeep/rails/configuration.rb', line 23 def matches_dependency?(dependency) case source when :current dependency.source == :current_attribute && (dependency, :owner) == source_key.fetch(:owner) && (dependency, :name) == source_key.fetch(:name) when :session dependency.source == :session && (dependency, :key) == source_key when :cookie dependency.source == :cookie && (dependency, :key) == source_key when :warden dependency.source == :warden_user && (dependency, :scope) == source_key else false end end |
#source_label ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/upkeep/rails/configuration.rb', line 40 def source_label case source when :current "#{source_key.fetch(:owner)}.#{source_key.fetch(:name)}" when :session "session[:#{source_key}]" when :cookie "cookies[:#{source_key}]" when :warden "warden.user(:#{source_key})" end end |