Ticket #390 (new defect)

Opened 7 months ago

:order => :foo in grouping.rb does not catch unacceptable values

Reported by: ruport Assigned to:
Milestone: Keywords:
Cc:

Description

      lvl_grouping = ::Ruport::Data::Grouping.new(
         options.lvldata, 
         :by => :ssid,
         :order => :foo)

:order accepts a code block or :name as parameters. However, if a value for :order is unknown, the grouping.rb processing will continue as though no :order parameter was given at all. I think this is a bug, and should be investigated. Maybe something like the following?

    # Iterates through the Grouping, yielding each group name and 
    # Group object
    def each
      if @order.respond_to?(:call)
        @data.sort_by { |n,g| @order[g] }.each { |n,g| yield(n,g) }
      elsif @order == :name
        @data.sort_by { |n,g| n }.each { |name,group| yield(name,group) }
      elsif @order.nil?
        @data.each { |name,group| yield(name,group) }
      else
        # do something to bring an end to application
      end
    end