Sha256: ad980bea6a4615898baeac534dcfb7172a16e8a2f86707493041f363301a6e99

Contents?: true

Size: 763 Bytes

Versions: 67

Compression:

Stored size: 763 Bytes

Contents

module Appstats
  class Context < ActiveRecord::Base
    set_table_name "appstats_contexts"
    belongs_to :entry, :foreign_key => "appstats_entry_id"
    attr_accessible :context_key, :context_value
  
    def context_value=(value)
      self[:context_value] = value
      self[:context_int] = nil
      self[:context_float] = nil
      return if value.nil?
      as_int = value.to_i
      as_float = value.to_f
      self[:context_int] = as_int if as_int.to_s == value
      self[:context_float] = as_float if as_float.to_s == value || !self[:context_int].nil?
    end
  
    def to_s
      return "No Context" if context_key.nil? || context_key == ''
      "#{context_key}[]" if context_value.nil?
      "#{context_key}[#{context_value}]"
    end
  
  end
end

Version data entries

67 entries across 67 versions & 1 rubygems

Version Path
appstats-0.21.3 lib/appstats/context.rb
appstats-0.21.2 lib/appstats/context.rb
appstats-0.21.1 lib/appstats/context.rb
appstats-0.20.12 lib/appstats/context.rb
appstats-0.20.11 lib/appstats/context.rb
appstats-0.20.10 lib/appstats/context.rb
appstats-0.20.9 lib/appstats/context.rb
appstats-0.20.8 lib/appstats/context.rb
appstats-0.20.7 lib/appstats/context.rb
appstats-0.20.6 lib/appstats/context.rb
appstats-0.20.2 lib/appstats/context.rb
appstats-0.20.1 lib/appstats/context.rb
appstats-0.20.0 lib/appstats/context.rb
appstats-0.19.7 lib/appstats/context.rb
appstats-0.19.6 lib/appstats/context.rb
appstats-0.19.2 lib/appstats/context.rb
appstats-0.19.1 lib/appstats/context.rb
appstats-0.19.0 lib/appstats/context.rb
appstats-0.18.0 lib/appstats/context.rb
appstats-0.17.5 lib/appstats/context.rb