lib/bindata/choice.rb in bindata-2.4.15 vs lib/bindata/choice.rb in bindata-2.5.0
- old
+ new
@@ -80,22 +80,23 @@
def selection
selection = eval_parameter(:selection)
if selection.nil?
raise IndexError, ":selection returned nil for #{debug_name}"
end
+
selection
end
- def respond_to?(symbol, include_private = false) #:nodoc:
- current_choice.respond_to?(symbol, include_private) || super
+ def respond_to?(symbol, include_all = false) # :nodoc:
+ current_choice.respond_to?(symbol, include_all) || super
end
- def method_missing(symbol, *args, &block) #:nodoc:
+ def method_missing(symbol, *args, &block) # :nodoc:
current_choice.__send__(symbol, *args, &block)
end
- %w(clear? assign snapshot do_read do_write do_num_bytes).each do |m|
+ %w[clear? assign snapshot do_read do_write do_num_bytes].each do |m|
module_eval <<-END
def #{m}(*args)
current_choice.#{m}(*args)
end
END
@@ -110,17 +111,19 @@
end
def instantiate_choice(selection)
prototype = get_parameter(:choices)[selection]
if prototype.nil?
- raise IndexError, "selection '#{selection}' does not exist in :choices for #{debug_name}"
+ msg = "selection '#{selection}' does not exist in :choices for #{debug_name}"
+ raise IndexError, msg
end
+
prototype.instantiate(nil, self)
end
end
class ChoiceArgProcessor < BaseArgProcessor
- def sanitize_parameters!(obj_class, params) #:nodoc:
+ def sanitize_parameters!(obj_class, params) # :nodoc:
params.merge!(obj_class.dsl_params)
params.sanitize_choices(:choices) do |choices|
hash_choices = choices_as_hash(choices)
ensure_valid_keys(hash_choices)