Class: Appstats::Context

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/appstats/context.rb

Instance Method Summary collapse

Instance Method Details

#context_value=(value) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/appstats/context.rb', line 10

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

#to_sObject



21
22
23
24
25
# File 'lib/appstats/context.rb', line 21

def to_s
  return "No Context" if context_key.nil? || context_key == ''
  "#{context_key}[]" if context_value.nil?
  "#{context_key}[#{context_value}]"
end