Class: Sessions
- Inherits:
-
Entities
- Object
- RPCQooxdooService
- Entities
- Sessions
- Defined in:
- lib/qooxview/helpers/session.rb
Overview
This class represents the actual session and holds the following
information:
- "entity_name" - chosen entities
- "id" - the actual id of the session
- "permissions" - instance of Permission
- "owner" - who called the session
Instance Attribute Summary
Attributes inherited from Entities
#blocks, #changed, #data, #data_class, #data_field_id, #data_instances, #is_loaded, #keys, #last_id, #loading, #name, #null_allowed, #save_after_create, #storage, #values
Instance Method Summary collapse
-
#create(owner = nil, sid = nil) ⇒ Object
Adds a person with a session.
- #loaded ⇒ Object
- #setup_data ⇒ Object
Methods inherited from Entities
delete_all_data, #get_block_fields, #get_data_instance, #get_field_names, #get_non_list_field_names, #get_value, has_entity?, #initialize, is_setup?, load, load_all, #match_by_id, method_missing, #method_missing, needs, reload, #respond_to?, save_all, service, #singular, #value_add, #value_add_, #value_block, #value_date, #value_entity, #value_int, #value_list_drop_, #value_str, #value_time, #whoami
Methods included from StorageHandler
#add_new_storage, #add_value_to_storage, #create_key, #data_update, #delete_all, #delete_id, #field_args, #filter_by, #find, #find_by, #find_key_by, #first, #get_entry, #has_field?, #has_storage?, #last, #load, #match_by, #match_key, #matches_by, #migrate, #new_id, #replace_st, #save, #save_data, #search_all, #search_all_, #search_by, #search_by_all, #set_entry, #update_key
Methods inherited from RPCQooxdooService
add_prime_service, entities, #get_services, inherited, #initialize, migrate_all, needs, #needs_covered, services
Constructor Details
This class inherits a constructor from Entities
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Entities
Instance Method Details
#create(owner = nil, sid = nil) ⇒ Object
Adds a person with a session.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/qooxview/helpers/session.rb', line 20 def create(owner = nil, sid = nil) if !sid sid = rand end if owner if owner.session_id and old = match_by_sid(owner.session_id) old.delete end owner.session_id = sid.to_s end s = super(owner: owner, sid: sid.to_s, s_data: {}, last_seen: Time.now.to_i) s.web_req = nil s.client_ip = nil return s end |
#loaded ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/qooxview/helpers/session.rb', line 39 def loaded before = @data.length # Reject all sessions that never got opened and those who are older than one day @data.delete_if { |k, v| !v._owner || (v._last_seen && Time.now.to_i - v._last_seen.to_i > 86_400) } dputs(3) { "Cleaning up: from #{before} to #{@data.length}" } end |
#setup_data ⇒ Object
12 13 14 15 16 17 |
# File 'lib/qooxview/helpers/session.rb', line 12 def setup_data value_entity_person :owner, :drop, :full_name value_str :sid value_str :s_data value_str :last_seen end |