Class: Rapid::Setting::BooleanSetting
- Defined in:
- lib/rapid/setting/boolean_setting.rb
Instance Attribute Summary
Attributes inherited from Base
#default_value, #full_name, #name, #namespace
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from Rapid::Setting::Base
Instance Method Details
#define_helpers(klass) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rapid/setting/boolean_setting.rb', line 18 def define_helpers klass super name = self.name getter = self.name klass.class_eval do define_method "#{getter}?" do self[name] == true end end true end |
#load(value) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/rapid/setting/boolean_setting.rb', line 6 def load value if value == nil || value == "" nil elsif [0, "0", false, "false"].include?(value) false elsif [1, "1", true, "true"].include?(value) true else raise Rapid::InvalidSettingError.new(self, value) end end |