Sha256: 55562e8686286a26665fd69ea4de63c7542527216dd6d90058513ac79fdbe0a6

Contents?: true

Size: 887 Bytes

Versions: 4

Compression:

Stored size: 887 Bytes

Contents

# -*- coding: utf-8 -*-
require 'tengine/core'

class Tengine::Core::Session
  include Mongoid::Document
  include Mongoid::Timestamps
  include Tengine::Core::CollectionAccessible
  include Tengine::Core::OptimisticLock

  field :lock_version, :type => Integer, :default => 1
  field :properties, :type => Hash, :default => {}
  map_yaml_accessor :properties
  field :system_properties, :type => Hash, :default => {}
  map_yaml_accessor :system_properties

  has_one :driver, :class_name => "Tengine::Core::Driver"

  # 元々の[]と[]=メソッドをオーバーライドしているので要注意
  def [](key); properties[key]; end
  def []=(key, value); properties[key] = value; end

  def clear_properties
    self.properties = {}
  end

  def clear_system_properties
    self.system_properties = {}
  end

  def clear
    clear_properties
    clear_system_properties
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tengine_core-1.2.2 lib/tengine/core/session.rb
tengine_core-1.2.1 lib/tengine/core/session.rb
tengine_core-1.2.0 lib/tengine/core/session.rb
tengine_core-1.1.0 lib/tengine/core/session.rb