Class: Settis::ScalarSetting

Inherits:
Setting
  • Object
show all
Defined in:
lib/settis/settings/scalar.rb

Instance Attribute Summary

Attributes inherited from Setting

#name

Instance Method Summary collapse

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, options = {})
  @serializer = serializer
  @default = options.delete(:default)

  super(container, name, options)
end

Instance Method Details

#getObject



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