class Citrus::Common::Service::BackendSessionService::BackendSession

BackendSession

Public Class Methods

new(args={}) click to toggle source

Create a new backend session

@param [Hash] args @param [Object] service

# File lib/citrus/common/service/backend_session_service.rb, line 199
def initialize args={}, service
  args.each_pair { |key, value|
    instance_eval %Q{ @#{key} = value }
  }
  @session_service = service
end

Public Instance Methods

bind(uid) { |err| ... } click to toggle source

Bind current session with the user id

@param [String] uid

# File lib/citrus/common/service/backend_session_service.rb, line 209
def bind uid, &block
  @session_service.bind(@frontend_id, @id, uid) { |err|
    @uid = uid unless err
    block_given? and yield err
  }
end
export() click to toggle source

Export the key/values for serialization

# File lib/citrus/common/service/backend_session_service.rb, line 254
def export
  res = {}
  EXPORTED_FIELDS.each { |field|
    instance_eval %Q{ res['#{field}'] = @#{field} }
  }
  res
end
get(key) click to toggle source

Get the value from backend session by key

@param [String] key

# File lib/citrus/common/service/backend_session_service.rb, line 237
def get key
  @settings[key]
end
push(key, &block) click to toggle source

Push the key/value in backend session to the front internal session

@param [String] key

# File lib/citrus/common/service/backend_session_service.rb, line 244
def push key, &block
  @session_service.push @frontend_id, @id, key, get(key), &block
end
push_all(&block) click to toggle source

Push all the key/values in backend session to the frontend internal session

# File lib/citrus/common/service/backend_session_service.rb, line 249
def push_all &block
  @session_service.push_all @frontend_id, @id, @settings, &block
end
set(key, value) click to toggle source

Set the key/value into backend session

@param [String] key @param [Hash] value

# File lib/citrus/common/service/backend_session_service.rb, line 230
def set key, value
  @settings[key] = value
end
unbind(uid) { |err| ... } click to toggle source

Unbind current session with the user id

@param [String] uid

# File lib/citrus/common/service/backend_session_service.rb, line 219
def unbind uid, &block
  @session_service.unbind(@frontend_id, @id, uid) { |err|
    @uid = nil unless err
    block_given? and yield err
  }
end