Class: Attribool::Validators::ConditionValidator
- Inherits:
- 
      Object
      
        - Object
- Attribool::Validators::ConditionValidator
 
- Defined in:
- lib/attribool/validators/condition_validator.rb
Overview
Ensures that a condition is either nil or a Proc.
Instance Method Summary collapse
- 
  
    
      #error  ⇒ ArgumentError 
    
    
  
  
  
  
  
  
  
  
  
    The exception to raise if validations fail. 
- 
  
    
      #initialize(condition)  ⇒ ConditionValidator 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    Construct the validator. 
- 
  
    
      #valid?  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    Is the condition either nilor aProc?.
Constructor Details
#initialize(condition) ⇒ ConditionValidator
Construct the validator.
| 11 12 13 | # File 'lib/attribool/validators/condition_validator.rb', line 11 def initialize(condition) @condition = condition end | 
Instance Method Details
#error ⇒ ArgumentError
The exception to raise if validations fail.
| 27 28 29 | # File 'lib/attribool/validators/condition_validator.rb', line 27 def error ArgumentError.new("Condition is not a proc") end | 
#valid? ⇒ Boolean
Is the condition either nil or a Proc?
| 19 20 21 | # File 'lib/attribool/validators/condition_validator.rb', line 19 def valid? @condition.nil? || @condition.is_a?(Proc) end |