Sha256: e65d517792f1ac4fa786392bd414045a2c868972cd95a1ee20495c0ae0e467c3

Contents?: true

Size: 908 Bytes

Versions: 9

Compression:

Stored size: 908 Bytes

Contents

module Appstats
  class Context < ActiveRecord::Base
    set_table_name "appstats_contexts"
    establish_connection "appstats_#{Rails.env}" if configurations.keys.include?("appstats_#{Rails.env}")
    
    belongs_to :entry, :class_name => "Appstats::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

9 entries across 9 versions & 1 rubygems

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