Fixed module reference inside macro

This commit is contained in:
Ary Borenszweig 2016-09-28 14:46:34 -03:00
parent ae6a68f00e
commit 4f724475e0
2 changed files with 6 additions and 6 deletions

View file

@ -1,5 +1,5 @@
name: db
version: 0.1.0
version: 0.1.1
authors:
- Brian J. Cardiff <bcardiff@manas.com.ar>

View file

@ -58,7 +58,7 @@ module DB
#
# This macro also declares instance variables of the types given in the mapping.
macro mapping(properties, strict = true)
include DB::Mappable
include ::DB::Mappable
{% for key, value in properties %}
{% properties[key] = {type: value} unless value.is_a?(HashLiteral) || value.is_a?(NamedTupleLiteral) %}
@ -76,7 +76,7 @@ module DB
end
{% end %}
def self.from_rs(%rs : DB::ResultSet)
def self.from_rs(%rs : ::DB::ResultSet)
%objs = Array(self).new
%rs.each do
%objs << self.new(%rs)
@ -84,7 +84,7 @@ module DB
%objs
end
def initialize(%rs : DB::ResultSet)
def initialize(%rs : ::DB::ResultSet)
{% for key, value in properties %}
%var{key.id} = nil
%found{key.id} = false
@ -106,7 +106,7 @@ module DB
{% end %}
else
{% if strict %}
raise DB::MappingException.new("unknown result set attribute: #{col_name}")
raise ::DB::MappingException.new("unknown result set attribute: #{col_name}")
{% else %}
%rs.read
{% end %}
@ -116,7 +116,7 @@ module DB
{% for key, value in properties %}
{% unless value[:nilable] || value[:default] != nil %}
if %var{key.id}.is_a?(Nil) && !%found{key.id}
raise DB::MappingException.new("missing result set attribute: {{(value[:key] || key).id}}")
raise ::DB::MappingException.new("missing result set attribute: {{(value[:key] || key).id}}")
end
{% end %}
{% end %}