lib/bindata/choice.rb in bindata-1.1.0 vs lib/bindata/choice.rb in bindata-1.2.0

- old
+ new

@@ -52,11 +52,11 @@ # <tt>:copy_on_change</tt>:: If set to true, copy the value of the previous # selection to the current selection whenever the # selection changes. Default is false. class Choice < BinData::Base - register(self.name, self) + register_self mandatory_parameters :choices, :selection optional_parameter :copy_on_change class << self @@ -96,12 +96,12 @@ raise ArgumentError, ":choices hash may not have symbols for keys" end end end - def initialize(params = {}, parent = nil) - super(params, parent) + def initialize(parameters = {}, parent = nil) + super @choices = {} @last_selection = nil end @@ -131,12 +131,12 @@ # pc.selection = 5 # pc #=> "Type1" # # pc.selection = 17 # pc #=> "Type2" - def selection=(v) - raise NoMethodError + def selection=(sel) + raise NoMethodError, "See rdoc BinData::Choice.selection= for details" end def clear #:nodoc: current_choice.clear end @@ -144,11 +144,11 @@ def clear? #:nodoc: current_choice.clear? end def respond_to?(symbol, include_private = false) #:nodoc: - super || current_choice.respond_to?(symbol, include_private) + current_choice.respond_to?(symbol, include_private) || super end def method_missing(symbol, *args, &block) #:nodoc: current_choice.__send__(symbol, *args, &block) end @@ -162,14 +162,10 @@ end def trace_selection BinData::trace_message do |tracer| selection_string = eval_parameter(:selection).inspect - if selection_string.length > 30 - selection_string = selection_string.slice(0 .. 30) + "..." - end - - tracer.trace("#{debug_name}-selection- => #{selection_string}") + tracer.trace_obj("#{debug_name}-selection-", selection_string) end end def _done_read current_choice.done_read