Skip to content

Commit

Permalink
Prevent final user to include Clear::Model on struct-like object, since
Browse files Browse the repository at this point in the history
it behave strangely
  • Loading branch information
Yacine Petitprez committed May 25, 2018
1 parent 2434f05 commit 0db0a32
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/clear/model/model.cr
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ module Clear::Model
# The overload are shown in this case, but not in the case the constructors
# are directly defined without the included block.
macro included
{% raise "Do NOT include Clear::Model on struct-like objects.\n"+
"It would behave very strangely otherwise." unless @type < Reference %}

getter cache : Clear::Model::QueryCache?

def initialize(@persisted = false)
Expand Down
1 change: 1 addition & 0 deletions templates/kemal/src/db/init.ecr
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ def self.init_db
Clear::SQL.init(CLEAR_DB_CONFIG["uri"].as_s)
rescue DB::ConnectionRefused
puts "FATAL: Connection to the database (#{uri}) has been refused"
exit
end
end

0 comments on commit 0db0a32

Please sign in to comment.