Skip to content

Commit

Permalink
Using parse_caller to support proper parse the file name in mingw pla…
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric-Guo committed Jul 17, 2015
1 parent 357d0d4 commit 342901f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/active_model/serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def self.inherited(base)
base._attributes_keys = self._attributes_keys.try(:dup) || {}
base._associations = self._associations.try(:dup) || {}
base._urls = []
serializer_file = File.open(caller.first[/^[^:]+/])
serializer_file = File.open(parse_caller(caller.first).first)
base._cache_digest = Digest::MD5.hexdigest(serializer_file.read)
end

Expand Down Expand Up @@ -256,5 +256,13 @@ def self.get_serializer_for(klass)
end
end

def self.parse_caller(at)
if /^(.+?):(\d+)(?::in `(.*)')?/ =~ at
file = Regexp.last_match[1]
line = Regexp.last_match[2].to_i
method = Regexp.last_match[3]
[file, line, method]
end
end
end
end

0 comments on commit 342901f

Please sign in to comment.