Skip to content

Commit

Permalink
initialize instance variables
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed May 2, 2012
1 parent 1ef527f commit dc2352c
Showing 1 changed file with 5 additions and 6 deletions.
Expand Up @@ -124,6 +124,7 @@ def initialize(by, env)
@env = env
@delegate = {}
@loaded = false
@exists = nil # we haven't checked yet
end

def destroy
Expand Down Expand Up @@ -181,7 +182,7 @@ def inspect
end

def exists?
return @exists if instance_variable_defined?(:@exists)
return @exists unless @exists.nil?
@exists = @by.send(:session_exists?, @env)
end

Expand All @@ -205,18 +206,16 @@ def load_for_write!
end

def load!
id, session = @by.send(:load_session, @env)
id, session = @by.load_session @env
@env[ENV_SESSION_OPTIONS_KEY][:id] = id
@delegate.replace(stringify_keys(session))
@loaded = true
end

def stringify_keys(other)
hash = {}
other.each do |key, value|
other.each_with_object({}) { |(key, value), hash|
hash[key.to_s] = value
end
hash
}
end
end
end
Expand Down

0 comments on commit dc2352c

Please sign in to comment.