Class: Redstruct::Types::Base
- Inherits:
-
Object
- Object
- Redstruct::Types::Base
- Extended by:
- Forwardable
- Includes:
- Utils::Inspectable
- Defined in:
- lib/redstruct/types/base.rb
Overview
Base class for all objects a factory can produce
Instance Attribute Summary collapse
-
#key ⇒ String
readonly
The key used to identify the struct on redis.
Instance Method Summary collapse
-
#initialize(key:, factory:) ⇒ Base
constructor
A new instance of Base.
-
#inspectable_attributes ⇒ Object
:nocov:.
- #to_h ⇒ Object
- #with ⇒ Object
Methods included from Utils::Inspectable
Constructor Details
#initialize(key:, factory:) ⇒ Base
Returns a new instance of Base.
13 14 15 16 |
# File 'lib/redstruct/types/base.rb', line 13 def initialize(key:, factory:) @factory = factory @key = key end |
Instance Attribute Details
#key ⇒ String (readonly)
Returns The key used to identify the struct on redis.
11 12 13 |
# File 'lib/redstruct/types/base.rb', line 11 def key @key end |
Instance Method Details
#inspectable_attributes ⇒ Object
:nocov:
41 42 43 |
# File 'lib/redstruct/types/base.rb', line 41 def inspectable_attributes { key: @key, factory: @factory } end |
#to_h ⇒ Object
29 30 31 |
# File 'lib/redstruct/types/base.rb', line 29 def to_h return { key: @key } end |
#with ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/redstruct/types/base.rb', line 18 def with self.connection.pool.with do |c| begin Thread.current[:__redstruct_connection] = c yield(c) ensure Thread.current[:__redstruct_connection] = nil end end end |