Class | Settings::Setting |
In: |
lib/more/facets/settings.rb
|
Parent: | Object |
A datastructure to store Settings metadata.
Please note the difference between :default and :value, :default does NOT override :value.
name | [RW] | |
options | [RW] | |
owner | [RW] | |
type | [RW] | |
value | [RW] |
# File lib/more/facets/settings.rb, line 66 def initialize(owner, name, options) if options.key? :value @value = options[:value] elsif options.key? :default @value = options[:default] else raise ArgumentError.new('A value is required') end @owner, @name = owner, name @options = options @type = options[:type] = options[:type] || @value.class end
Text representation of this setting.
# File lib/more/facets/settings.rb, line 98 def to_s @value.to_s end
Update the setting from an options hash. The update does NOT take default values into account!
# File lib/more/facets/settings.rb, line 83 def update(hash) if hash.key? :value @value = hash[:value] @type = @value.class end if hash.key? :type @type = hash[:type] end @options.update(hash) end