Class: SimpleValidator
- Inherits:
-
Object
- Object
- SimpleValidator
- Defined in:
- lib/input_validator.rb
Overview
nil return is treated as no error
Constant Summary collapse
- CANNOT_CONTINUE =
'. Cannot continue!'
- IS_MISSING =
' is missing'
Instance Method Summary collapse
- #method_exists(object, method) ⇒ Object
- #method_value_not_nil(object, method) ⇒ Object
- #method_value_not_nil_or_empty(object, method) ⇒ Object
Instance Method Details
#method_exists(object, method) ⇒ Object
137 138 139 140 141 142 143 144 145 |
# File 'lib/input_validator.rb', line 137 def method_exists object, method begin if !object.respond_to? method "#{@node_name}\'s method: *#{method}*" + IS_MISSING end rescue nil end end |
#method_value_not_nil(object, method) ⇒ Object
158 159 160 161 162 163 164 165 166 167 |
# File 'lib/input_validator.rb', line 158 def method_value_not_nil object, method begin value = object.send method if value.nil? "#{@node_name}\'s *#{method}* value" + IS_MISSING end rescue nil end end |
#method_value_not_nil_or_empty(object, method) ⇒ Object
147 148 149 150 151 152 153 154 155 156 |
# File 'lib/input_validator.rb', line 147 def method_value_not_nil_or_empty object, method begin value = object.send method if value.nil? || value.to_s.strip.length == 0 "#{@node_name}\'s *#{method}* value is empty or" + IS_MISSING end rescue nil end end |