Class: Settis::ScalarSetting
- Defined in:
- lib/settis/settings/scalar.rb
Instance Attribute Summary
Attributes inherited from Setting
Instance Method Summary collapse
- #get ⇒ Object
-
#initialize(container, name, serializer, options = {}) ⇒ ScalarSetting
constructor
A new instance of ScalarSetting.
- #set(value) ⇒ Object
Constructor Details
#initialize(container, name, serializer, options = {}) ⇒ ScalarSetting
Returns a new instance of ScalarSetting.
19 20 21 22 23 24 |
# File 'lib/settis/settings/scalar.rb', line 19 def initialize(container, name, serializer, = {}) @serializer = serializer @default = .delete(:default) super(container, name, ) end |
Instance Method Details
#get ⇒ Object
26 27 28 29 |
# File 'lib/settis/settings/scalar.rb', line 26 def get value = @serializer.deserialize(super) value || @default end |
#set(value) ⇒ Object
31 32 33 34 |
# File 'lib/settis/settings/scalar.rb', line 31 def set(value) super(@serializer.serialize(value)) value end |