Sha256: 25fe5f1a76ac5ddcbdb101423645026ffad4f5dfd2d19a4d78aa47c3fbb9a051
Contents?: true
Size: 696 Bytes
Versions: 1
Compression:
Stored size: 696 Bytes
Contents
require 'captain_config/models/base_config' class CaptainConfig::BooleanConfig < CaptainConfig::BaseConfig def value case self.text when 'true' true when 'false' false else raise "Invalid text: #{text.inspect}" end end def value=(new_value) if new_value != true && new_value != false raise ArgumentError.new("Invalid value: #{new_value.inspect}") end self.text = new_value.to_s end def self.coerce(value) case value when 'true' true when 'false' false when true true when false false else raise ArgumentError.new("Cannot coerce value: #{value.inspect}") end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
captain_config-1.1.0 | lib/captain_config/models/boolean_config.rb |