Class: SharedSettings::SerializedSetting

Inherits:
Object
  • Object
show all
Defined in:
lib/shared_settings/serialized_setting.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, raw_value, encrypt: false) ⇒ SerializedSetting

Returns a new instance of SerializedSetting.



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/shared_settings/serialized_setting.rb', line 17

def initialize(name, raw_value, encrypt: false)
  @name = name.to_s
  @type = determine_type(raw_value)
  @encrypted = encrypt

  if encrypt
    stringified_value = serialize_raw_value(raw_value)
    @value = encrypt_value(stringified_value)
  else
    @value = serialize_raw_value(raw_value)
  end
end

Instance Attribute Details

#encryptedObject (readonly)

All data values are represented by strings (similar to Redis).

This means that, regardless of what adaptor is being implemented,
all adaptors must accept and return data in the format which we will outline.

Storage adaptors are only responsible for storing the setting as-given and returning
it in the expected format. Here is a list of formats and their string representation:

number: "1234"
string: "any string"
boolean: "1" or "0"
range: "low,high". eg: "1,5" *inclusive*


15
16
17
# File 'lib/shared_settings/serialized_setting.rb', line 15

def encrypted
  @encrypted
end

#nameObject (readonly)

All data values are represented by strings (similar to Redis).

This means that, regardless of what adaptor is being implemented,
all adaptors must accept and return data in the format which we will outline.

Storage adaptors are only responsible for storing the setting as-given and returning
it in the expected format. Here is a list of formats and their string representation:

number: "1234"
string: "any string"
boolean: "1" or "0"
range: "low,high". eg: "1,5" *inclusive*


15
16
17
# File 'lib/shared_settings/serialized_setting.rb', line 15

def name
  @name
end

#typeObject (readonly)

All data values are represented by strings (similar to Redis).

This means that, regardless of what adaptor is being implemented,
all adaptors must accept and return data in the format which we will outline.

Storage adaptors are only responsible for storing the setting as-given and returning
it in the expected format. Here is a list of formats and their string representation:

number: "1234"
string: "any string"
boolean: "1" or "0"
range: "low,high". eg: "1,5" *inclusive*


15
16
17
# File 'lib/shared_settings/serialized_setting.rb', line 15

def type
  @type
end

#valueObject (readonly)

All data values are represented by strings (similar to Redis).

This means that, regardless of what adaptor is being implemented,
all adaptors must accept and return data in the format which we will outline.

Storage adaptors are only responsible for storing the setting as-given and returning
it in the expected format. Here is a list of formats and their string representation:

number: "1234"
string: "any string"
boolean: "1" or "0"
range: "low,high". eg: "1,5" *inclusive*


15
16
17
# File 'lib/shared_settings/serialized_setting.rb', line 15

def value
  @value
end