Class: Dotum::AbstractRules::OptionsBase
- Defined in:
- lib/dotum/abstract_rules/options_base.rb
Direct Known Subclasses
GlobbableFiles, Rules::Download, Rules::Repo, Rules::RequireExtension, Rules::Use, Rules::UseRepo
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(context, options) ⇒ OptionsBase
constructor
A new instance of OptionsBase.
Methods inherited from Base
#exec, pretty, #pretty_subject
Methods included from RuleOptionsDSL
#eval_options_block, #expand_shorthand, #option_configs, #option_defaults, #optional, #preprocessor_methods, #register_preprocessor, #required, #shorthand, #shorthand_config, #standard, #validate_options
Methods included from RuleDSL
#available?, #failure!, #method_missing, #package_dir, #platform?, #skip!, #state_dir, #success!, #target_dir
Constructor Details
#initialize(context, options) ⇒ OptionsBase
Returns a new instance of OptionsBase.
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/dotum/abstract_rules/options_base.rb', line 22 def initialize(context, ) super(context) .each do |option, value| filter = self.class.option_configs[option][:filter] value = instance_exec(value, &filter) if filter && !value.nil? instance_variable_set(:"@#{option}", value) end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Dotum::RuleDSL
Class Method Details
.exec(context, *args, &block) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/dotum/abstract_rules/options_base.rb', line 5 def self.exec(context, *args, &block) = option_defaults.merge((*args)) .merge! (&block) if block if errors = () raise "Validation errors: #{errors.inspect}" end if respond_to? : (context, ).map { || new(context, ).exec } else new(context, ).exec end end |