From 817340c34f8287bc13424c0871240d1f52f20494 Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Fri, 15 Jul 2016 20:11:38 -0400 Subject: refactor context --- src/guff.cr | 29 ----------------------------- 1 file changed, 29 deletions(-) (limited to 'src/guff.cr') diff --git a/src/guff.cr b/src/guff.cr index c1acd8b..3fecd10 100644 --- a/src/guff.cr +++ b/src/guff.cr @@ -1325,35 +1325,6 @@ module Guff end end - class Context - getter :config, :dbs - - def initialize(@config : Config) - @dbs = DatabasePair.new(@config.db_path, development?) - end - - def models - @models ||= ModelSet.new(self) - end - - def session - @session ||= Session.new(self) - end - - def user_id : Int64? - session["user_id"]? ? session["user_id"].to_i64 : nil - end - - def has_role?(roles : Array(String)) - id = user_id - id ? models.user.has_role?(id, roles) : false - end - - def development? - @is_development ||= (@config.env == "development") as Bool - end - end - module APIs module PostAPI def do_post_get_posts(params : HTTP::Params) -- cgit v1.2.3