module Aquarium::Utils::OptionsUtils::ClassMethods

Public Instance Methods

add_exclude_options_for(option, options_hash) click to toggle source

Service method that adds a new canonical option and corresponding array with “exclude_” prepended to all values. The new options are added to the input hash.

    # File lib/aquarium/utils/options_utils.rb
196 def add_exclude_options_for option, options_hash
197   all_variants = options_hash[option].dup
198   options_hash["exclude_#{option}"] = all_variants.map {|x| "exclude_#{x}"}
199 end
add_prepositional_option_variants_for(option, options_hash) click to toggle source

Service method that adds a new canonical option and corresponding array with “preposition” prefixes, e.g., “on_”, “for_”, etc. prepended to all values. The new options are added to the input hash.

    # File lib/aquarium/utils/options_utils.rb
204 def add_prepositional_option_variants_for option, options_hash
205   all_variants = options_hash[option].dup + [option]
206   OptionsUtils.universal_prepositions.each do |prefix|
207     all_variants.each do |variant|
208       options_hash[option] << "#{prefix}_#{variant}" 
209     end
210   end
211 end
canonical_option_accessor(*canonical_option_key_list) click to toggle source
    # File lib/aquarium/utils/options_utils.rb
174 def canonical_option_accessor *canonical_option_key_list
175   canonical_option_reader *canonical_option_key_list
176   canonical_option_writer *canonical_option_key_list
177 end
canonical_option_reader(*canonical_option_key_list) click to toggle source
    # File lib/aquarium/utils/options_utils.rb
156 def canonical_option_reader *canonical_option_key_list
157   return if canonical_option_key_list.nil? or canonical_option_key_list.empty?
158   keys = determine_options_for_accessors canonical_option_key_list
159   keys.each do |name|
160     define_method(name) do 
161       @specification[name]
162     end
163   end
164 end
canonical_option_writer(*canonical_option_key_list) click to toggle source
    # File lib/aquarium/utils/options_utils.rb
165 def canonical_option_writer *canonical_option_key_list
166   return if canonical_option_key_list.nil? or canonical_option_key_list.empty?
167   keys = determine_options_for_accessors canonical_option_key_list
168   keys.each do |name|
169     define_method("#{name}=") do |value|
170       @specification[name] = make_set(make_array(value))
171     end
172   end
173 end
canonical_options_given_methods(canonical_options) click to toggle source
    # File lib/aquarium/utils/options_utils.rb
179         def canonical_options_given_methods canonical_options
180           keys = canonical_options.respond_to?(:keys) ? canonical_options.keys : canonical_options 
181           (keys + OptionsUtils::universal_options).each do |name|
182             module_eval(<<-EOF, __FILE__, __LINE__)
183               def #{name}_given
184                 @specification[:#{name}]
185               end
186   
187               def #{name}_given?
188                 not (#{name}_given.nil? or #{name}_given.empty?)
189               end
190             EOF
191           end
192         end