def check(path_prefix, key_path, predicate = nil)
      value = query(key_path, path_prefix)

      # we have a value, any value, which is good enough given no predicate
      return true if !value.nil? && predicate.nil?

      case predicate
      when ::String, ::Regexp, ::Integer, ::Float, ::DateTime, true, false
        return predicate === value
      when ::Proc
        # Cannot use === here as above due to different behavior in Ruby 1.8
        return predicate.call(value)
      when nil
        return !value.nil?
      else
        raise AttributorException, "predicate not supported: #{predicate.inspect}"
      end
    end
def check(path_prefix, key_path, predicate = nil)
      value = query(key_path, path_prefix)

      # we have a value, any value, which is good enough given no predicate
      return true if !value.nil? && predicate.nil?

      case predicate
      when ::String, ::Regexp, ::Integer, ::Float, ::DateTime, true, false
        return predicate === value
      when ::Proc
        # Cannot use === here as above due to different behavior in Ruby 1.8
        return predicate.call(value)
      when nil
        return !value.nil?
      else
        raise AttributorException, "predicate not supported: #{predicate.inspect}"
      end
    end
Checks that the the condition is met. This means the attribute identified
 by path_prefix and key_path satisfies the optional predicate, which when
 nil simply checks for existence.

 @param path_prefix [String]
 @param key_path [String]
 @param predicate [String|Regexp|Proc|NilClass]

 @returns [Boolean] True if :required_if condition is met, false otherwise

 @raise [AttributorException] When an unsupported predicate is passed