Class: HashyValueValidator
- Inherits:
-
Object
- Object
- HashyValueValidator
- Defined in:
- lib/hashy_validator/hashy_value_validator.rb
Instance Attribute Summary collapse
-
#boolean_attrs ⇒ Object
readonly
Returns the value of attribute boolean_attrs.
-
#reason ⇒ Object
readonly
Returns the value of attribute reason.
-
#unique_attrs ⇒ Object
readonly
Returns the value of attribute unique_attrs.
-
#validations ⇒ Object
readonly
Returns the value of attribute validations.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(value, options = {}) ⇒ HashyValueValidator
constructor
A new instance of HashyValueValidator.
- #valid? ⇒ Boolean
Constructor Details
#initialize(value, options = {}) ⇒ HashyValueValidator
Returns a new instance of HashyValueValidator.
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/hashy_validator/hashy_value_validator.rb', line 4 def initialize(value, = {}) @value = value.blank? ? [] : value @valid = true @reason = nil @validations = {} @unique_attrs = {} @boolean_attrs = [] check_parse_value define_validations() end |
Instance Attribute Details
#boolean_attrs ⇒ Object (readonly)
Returns the value of attribute boolean_attrs.
20 21 22 |
# File 'lib/hashy_validator/hashy_value_validator.rb', line 20 def boolean_attrs @boolean_attrs end |
#reason ⇒ Object (readonly)
Returns the value of attribute reason.
20 21 22 |
# File 'lib/hashy_validator/hashy_value_validator.rb', line 20 def reason @reason end |
#unique_attrs ⇒ Object (readonly)
Returns the value of attribute unique_attrs.
20 21 22 |
# File 'lib/hashy_validator/hashy_value_validator.rb', line 20 def unique_attrs @unique_attrs end |
#validations ⇒ Object (readonly)
Returns the value of attribute validations.
20 21 22 |
# File 'lib/hashy_validator/hashy_value_validator.rb', line 20 def validations @validations end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
20 21 22 |
# File 'lib/hashy_validator/hashy_value_validator.rb', line 20 def value @value end |
Class Method Details
.get_boolean_value(value) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/hashy_validator/hashy_value_validator.rb', line 22 def self.get_boolean_value(value) return true if [true, "true"].include?(value) return false if [false, "false"].include?(value) nil end |
Instance Method Details
#valid? ⇒ Boolean
16 17 18 |
# File 'lib/hashy_validator/hashy_value_validator.rb', line 16 def valid? @valid end |