Class: Zetto::Storage::Session::Create
- Inherits:
-
Object
- Object
- Zetto::Storage::Session::Create
- Defined in:
- lib/zetto/storage/session/create.rb
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(user, user_agent, remote_ip) ⇒ Create
constructor
A new instance of Create.
Constructor Details
#initialize(user, user_agent, remote_ip) ⇒ Create
Returns a new instance of Create.
5 6 7 8 9 10 |
# File 'lib/zetto/storage/session/create.rb', line 5 def initialize(user, user_agent, remote_ip) @redis = Zetto::Storage::Connect::RedisSingelton.get @user = user @user_agent = user_agent @remote_ip = remote_ip end |
Instance Method Details
#execute ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/zetto/storage/session/create.rb', line 12 def execute begin new_session_data = nil 5.times do new_session_data = {} new_session_data["user_id"] = @user.id new_session_data["session_id"] = genrate_session_id new_session_data["algorithm"] = generate_random_algorithm new_session_data["class_name"] = @user.class.to_s new_session_data["user_agent"] = Digest::MD5.hexdigest(@user_agent) new_session_data["remote_ip"] = @remote_ip if validate_session_id_uniq?(new_session_data["session_id"]) remove_old_hash! return save(new_session_data) end end nil rescue Exception => e Zetto::Services::Info. I18n.t('exseptions.unknown_error', argument: 'Zetto::Storage::Session::Create', current_method: __method__), e nil end end |