Class: Kredis::Types::Scalar

Inherits:
Proxying show all
Defined in:
lib/kredis/types/scalar.rb

Instance Attribute Summary collapse

Attributes inherited from Proxying

#key, #proxy, #redis

Instance Method Summary collapse

Methods inherited from Proxying

#initialize, proxying

Constructor Details

This class inherits a constructor from Kredis::Types::Proxying

Instance Attribute Details

#defaultObject

Returns the value of attribute default.



4
5
6
# File 'lib/kredis/types/scalar.rb', line 4

def default
  @default
end

#typedObject

Returns the value of attribute typed.



4
5
6
# File 'lib/kredis/types/scalar.rb', line 4

def typed
  @typed
end

Instance Method Details

#assigned?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/kredis/types/scalar.rb', line 18

def assigned?
  exists?
end

#clearObject



22
23
24
# File 'lib/kredis/types/scalar.rb', line 22

def clear
  del
end

#to_sObject



14
15
16
# File 'lib/kredis/types/scalar.rb', line 14

def to_s
  get || default&.to_s
end

#valueObject



10
11
12
# File 'lib/kredis/types/scalar.rb', line 10

def value
  string_to_type(get, typed) || default
end

#value=(value) ⇒ Object



6
7
8
# File 'lib/kredis/types/scalar.rb', line 6

def value=(value)
  set type_to_string(value)
end