Sha256: ee0f95236a13299cbd853c3f26d5a0633d3ca1718b26181cad19a6013cf4891b

Contents?: true

Size: 982 Bytes

Versions: 3

Compression:

Stored size: 982 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, :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

3 entries across 3 versions & 1 rubygems

Version Path
appstats-0.22.3 lib/appstats/sub_result.rb
appstats-0.22.2 lib/appstats/sub_result.rb
appstats-0.22.1 lib/appstats/sub_result.rb