lib/rsence/plugins/plugin.rb in rsence-pre-2.2.0.38 vs lib/rsence/plugins/plugin.rb in rsence-pre-2.2.2.0
- old
+ new
@@ -195,14 +195,22 @@
# @param [Symbol] key (optional) returns a ses key, if defined.
#
# @return [Hash] Plugin-specific session hash
def get_ses( msg, key=false )
name_sym = name_with_manager_s.to_sym
- unless msg.session.has_key?( name_sym )
- msg.session[ name_sym ] = {}
+ if msg.class == RSence::Message
+ session = msg.session
+ elsif msg.class == Hash
+ session = msg
+ else
+ warn "Invalid class (#{msg.class}) for get_ses in #{name_sym.inspect}!"
+ return nil
end
- ses = msg.session[ name_sym ]
+ unless session.has_key?( name_sym )
+ session[ name_sym ] = {}
+ end
+ ses = session[ name_sym ]
return ses[key] if key
return ses
end
# Returns the source code of the javascript file +js_name+ in the 'js' subdirectory of the plugin bundle. Use it to send raw javascript command code to the client. Use {#read_js_once} for libraries.
@@ -660,10 +668,9 @@
# @private Restores session values to default, unless specified otherwise.
#
# Called from +#restore_ses+
def restore_ses_values( msg )
return unless @values
- ses = get_ses( msg )
if @values.class == Array
@values.each do | value_item |
value_item.each do | value_name, value_properties |
restore_ses_value( msg, value_name, value_properties )
end