lib/swing_support/extensions/attributes.rb in swing-0.1.12 vs lib/swing_support/extensions/attributes.rb in swing-0.1.14

- old
+ new

@@ -42,11 +42,11 @@ end # Sets attributes after calling original new def new_with_attributes(*args, &block) opts = args.last.is_a?(Hash) ? args.pop.dup : {} - component = self.new_without_attributes(*args, &block) + component = self.new_without_attributes(*args) #, &block) # Extract known attributes given in opts, # run default actions on them, or return known defaults attributes = attributes().map do |name, default| value = opts.delete name @@ -60,12 +60,10 @@ value.nil? ? default : value end [name, result] unless result.nil? end.compact - # yield opts if block_given? - attributes.each do |(name, value)| if component.respond_to? "#{name}=" component.send "#{name}=", *value elsif component.respond_to? "set_#{name}" component.send "set_#{name}", *value @@ -77,9 +75,12 @@ # Post-process non-setter opts (setter opts are already consumed by now) component.post_process opts # Raises exception if any of the given options left unprocessed raise "Unrecognized options: #{opts}" unless opts.empty? + + yield component if block_given? + component end end end end