Sha256: 4cb215cc6333e4a4d1370c386b543b05d9b8e76153783d29f3412621bdc8f9ea

Contents?: true

Size: 1017 Bytes

Versions: 9

Compression:

Stored size: 1017 Bytes

Contents

module Appstats
  class SubResult < ActiveRecord::Base
    set_table_name "appstats_sub_results"
    establish_connection "appstats_#{Rails.env}" if configurations.keys.include?("appstats_#{Rails.env}")

    attr_accessible :context_filter, :count, :ratio_of_total
    belongs_to :result, :class_name => "Appstats::Result", :foreign_key => "appstats_result_id"

    def total_count
      return 0 if result.nil?
      result.count
    end

    def count_to_s(data = {})
      Appstats::Result.calculate_count_to_s(count,data)
    end

    def total_count_to_s(data = {})
      Appstats::Result.calculate_count_to_s(total_count,data)
    end
    
    def context_filter_to_s
      return "-- N/A --" if context_filter.nil?
      return "-- No Value --" if context_filter.empty?
      context_filter
    end


    def ==(o)
       o.class == self.class && o.send(:state) == state
    end
    alias_method :eql?, :==

    private

      def state
        [context_filter, count, ratio_of_total]
      end

    
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
appstats-0.23.5 lib/appstats/sub_result.rb
appstats-0.23.4 lib/appstats/sub_result.rb
appstats-0.23.3 lib/appstats/sub_result.rb
appstats-0.23.2 lib/appstats/sub_result.rb
appstats-0.23.1 lib/appstats/sub_result.rb
appstats-0.23.0 lib/appstats/sub_result.rb
appstats-0.22.6 lib/appstats/sub_result.rb
appstats-0.22.5 lib/appstats/sub_result.rb
appstats-0.22.4 lib/appstats/sub_result.rb