Class: Katalyst::Healthcheck::Store::Attribute
- Inherits:
-
Object
- Object
- Katalyst::Healthcheck::Store::Attribute
- Defined in:
- lib/katalyst/healthcheck/store/attributes.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Instance Method Summary collapse
-
#initialize(key) ⇒ Attribute
constructor
A new instance of Attribute.
- #read(attributes) ⇒ Object
- #write(attributes, value) ⇒ Object
Constructor Details
#initialize(key) ⇒ Attribute
Returns a new instance of Attribute.
53 54 55 |
# File 'lib/katalyst/healthcheck/store/attributes.rb', line 53 def initialize(key) @key = key end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
51 52 53 |
# File 'lib/katalyst/healthcheck/store/attributes.rb', line 51 def key @key end |
Instance Method Details
#read(attributes) ⇒ Object
57 58 59 |
# File 'lib/katalyst/healthcheck/store/attributes.rb', line 57 def read(attributes) deserialize(attributes[key]) if attributes.has_key?(key) end |
#write(attributes, value) ⇒ Object
61 62 63 64 65 66 67 68 69 |
# File 'lib/katalyst/healthcheck/store/attributes.rb', line 61 def write(attributes, value) if value.nil? attributes.delete(key) elsif value.is_a?(String) # support already serialized values attributes[key] = value else attributes[key] = serialize(value) end end |