Class: SharedSettings::SerializedSetting
- Inherits:
-
Object
- Object
- SharedSettings::SerializedSetting
- Defined in:
- lib/shared_settings/serialized_setting.rb
Instance Attribute Summary collapse
-
#encrypted ⇒ Object
readonly
All data values are represented by strings (similar to Redis).
-
#name ⇒ Object
readonly
All data values are represented by strings (similar to Redis).
-
#type ⇒ Object
readonly
All data values are represented by strings (similar to Redis).
-
#value ⇒ Object
readonly
All data values are represented by strings (similar to Redis).
Instance Method Summary collapse
-
#initialize(name, raw_value, encrypt: false) ⇒ SerializedSetting
constructor
A new instance of SerializedSetting.
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
#encrypted ⇒ Object (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 |
#name ⇒ Object (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 |
#type ⇒ Object (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 |
#value ⇒ Object (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 |