Skip to content

Commit

Permalink
Default engine is already set on Config#initialize (#51)
Browse files Browse the repository at this point in the history
There is no need to have set_default_engine or engine_set flag since the
default is already set on the initialization
  • Loading branch information
felipeelias authored and Serdar Dogruyol committed Jul 2, 2017
1 parent bbef25f commit d438136
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
5 changes: 2 additions & 3 deletions src/kemal-session/base.cr
Expand Up @@ -10,7 +10,6 @@ class Session
@context : HTTP::Server::Context?

def initialize(ctx : HTTP::Server::Context)
Session.config.set_default_engine unless Session.config.engine_set?
id = ctx.request.cookies[Session.config.cookie_name]?.try &.value
valid = false
if id
Expand All @@ -28,7 +27,7 @@ class Session
end

ctx.response.cookies << Session.create_cookie(id)
@id = id
@id = id
@context = ctx
end

Expand All @@ -38,7 +37,7 @@ class Session
# check on the session_id
#
def initialize(id : String)
@id = id
@id = id
@context = nil
end

Expand Down
15 changes: 2 additions & 13 deletions src/kemal-session/config.cr
Expand Up @@ -9,18 +9,11 @@ class Session
@secret : String
@secure : Bool
@domain : String?
@path : String
@path : String
property timeout, gc_interval, cookie_name, engine, secret, secure, domain, path

@engine_set = false

def engine_set?
@engine_set
end

def engine=(e : Engine)
@engine = e
@engine_set = true
end

def initialize
Expand All @@ -31,11 +24,7 @@ class Session
@secret = ""
@secure = false
@domain = nil
@path = "/"
end

def set_default_engine
Session.config.engine = MemoryEngine.new
@path = "/"
end
end # Config

Expand Down

0 comments on commit d438136

Please sign in to comment.