Project

General

Profile

Feature #23143

Updated by Martin Bacovsky about 7 years ago

We need easier way to add custom option sources and validations.  
 In both the ordering matters so we need to be able to specify where the operation should happen. 

 Example of block that should add option source resolving custom option right after resulution  
 of decumented options and doing some validation after all sources are done 
 <pre> 
 class MyCommand 

   evaluate_options do 
     add_source(:after => :id_params, :source => :id_params) { CustomIdParams(self, :required_params => :object_id)) 
     add_source(:at => :start) { |defined_options, result| result.merge('option' => 'value') :object_id) } 
     add_validation(:at => :end) do 
       any(:option_a, :option_b).required 
     end 
   end 

   build_options 
 end 
 </pre>

Back