Method: Attributor::Type::ClassMethods#check_option!
- Defined in:
- lib/attributor/type.rb
#check_option!(name, definition) ⇒ Object
HELPER FUNCTIONS
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/attributor/type.rb', line 127 def check_option!(name, definition) case name when :min raise AttributorException, "Value for option :min does not implement '<='. Got: (#{definition.inspect})" unless definition.respond_to?(:<=) when :max raise AttributorException, "Value for option :max does not implement '>='. Got(#{definition.inspect})" unless definition.respond_to?(:>=) when :regexp # could go for a respoind_to? :=~ here, but that seems overly... cute... and not useful. raise AttributorException, "Value for option :regexp is not a Regexp object. Got (#{definition.inspect})" unless definition.is_a? ::Regexp else return :unknown end :ok end |