class ActiveSupport::Cache::MongoidStore::Entry

this class exists to normalize between rails3 and rails4, but also to repair totally broken interfaces in rails - especially in rails3 - that result in lots of extra serialization/deserialzation in a class which is supposed to be FAST

this class exists to normalize between rails3 and rails4, but also to repair totally broken interfaces in rails - especially in rails3 - that result in lots of extra serialization/deserialzation in a class which is supposed to be FAST

Public Class Methods

data_for(entry) click to toggle source
# File lib/active_support/cache/mongoid-store.rb, line 77
def Entry.data_for(entry)
  value = entry.instance_variable_get('@value')
  marshaled = value.nil? ? Marshal.dump(value) : value
  Moped::BSON::Binary.new(:generic, marshaled)
end
for(doc) click to toggle source
# File lib/active_support/cache/mongoid-store.rb, line 101
def Entry.for(doc)
  data = doc['data'].to_s
  value = Marshal.load(data)
  created_at = doc['created_at'].to_f

  allocate.tap do |entry|
    entry.instance_variable_set(:@value, value)
    entry.instance_variable_set(:@compressed, false)
    entry.instance_variable_set(:@created_at, created_at)
  end
end
is_rails3?() click to toggle source
# File lib/active_support/cache/mongoid-store.rb, line 60
def Entry.is_rails3?
  unless defined?(@is_rails3)
    @is_rails3 = new(nil).instance_variable_defined?('@value')
  end

  @is_rails3
end

Public Instance Methods

raw_value() click to toggle source
# File lib/active_support/cache/mongoid-store.rb, line 132
def raw_value
  Entry.is_rails3? ? @value : @v
end
value() click to toggle source
# File lib/active_support/cache/mongoid-store.rb, line 128
def value
  Entry.is_rails3? ? @value : @v
end