Module: Gricer::ActiveModel::Session

Included in:
Gricer::ActiveRecord::Session, Mongoid::Session
Defined in:
lib/gricer/active_model/session.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object

Extend the ActiveModel with the statistics class methods.

See Also:



8
9
10
# File 'lib/gricer/active_model/session.rb', line 8

def self.included(base)
  base.extend ClassMethods
end

Instance Method Details

#durationObject

Get the duration of the current session instance



92
93
94
# File 'lib/gricer/active_model/session.rb', line 92

def duration
  updated_at - created_at
end

#flash_version=(version) ⇒ Object



83
84
85
86
# File 'lib/gricer/active_model/session.rb', line 83

def flash_version=(version)
  self[:flash_version] = version
  self.flash_major_version = flash_version.match(/^([0-9]*\.[0-9]*)/).to_a.last if flash_version
end

#ip_address=(ip) ⇒ Object



62
63
64
# File 'lib/gricer/active_model/session.rb', line 62

def ip_address=(ip)
  self.attributes = Gricer::Parsers::Ip.get_info(ip)
end

#requested_localeObject



70
71
72
73
74
75
76
# File 'lib/gricer/active_model/session.rb', line 70

def requested_locale
  if requested_locale_minor
    "#{requested_locale_major}-#{requested_locale_minor}"
  else
    requested_locale_major
  end
end

#requested_locale=(locale) ⇒ Object



66
67
68
# File 'lib/gricer/active_model/session.rb', line 66

def requested_locale=(locale)
  self.requested_locale_major, self.requested_locale_minor = locale.try(:downcase).try(:split, '-')
end

#silverlight_version=(version) ⇒ Object



78
79
80
81
# File 'lib/gricer/active_model/session.rb', line 78

def silverlight_version=(version)
  self[:silverlight_version] = version
  self.silverlight_major_version = silverlight_version.match(/^([0-9]*\.[0-9]*)/).to_a.last if silverlight_version
end