lib/heimdallr/proxy/record.rb in heimdallr-1.0.2 vs lib/heimdallr/proxy/record.rb in heimdallr-1.0.3
- old
+ new
@@ -193,10 +193,15 @@
"Attempt to fetch insecure association #{method}. Try #insecure"
end
elsif @record.respond_to? method
if [nil, '?'].include?(suffix)
if @restrictions.allowed_fields[:view].include?(normalized_method)
- @record.send method, *args, &block
+ result = @record.send method, *args, &block
+ if result.respond_to? :restrict
+ result.restrict(@context, @options)
+ else
+ result
+ end
elsif @options[:implicit]
nil
else
raise Heimdallr::PermissionError, "Attempt to fetch non-whitelisted attribute #{method}"
end
\ No newline at end of file