lib/delorean/base.rb in delorean_lang-0.3.22 vs lib/delorean/base.rb in delorean_lang-0.3.23
- old
+ new
@@ -1,10 +1,14 @@
require 'active_support/time'
+require 'active_record'
require 'bigdecimal'
module Delorean
+ # FIXME: add string.gsub; Also, should be able to index regex
+ # matches. Need string.length.
+
# FIXME: the whitelist is quite hacky. It's currently difficult to
# override it. A user will likely want to directly modify this
# hash. The whole whitelist mechanism should be eventually
# rethought.
RUBY_WHITELIST = {
@@ -29,12 +33,12 @@
transpose: [Array],
join: [Array, String],
zip: [Array, [Array, Array, Array]],
index: [Array, [Object]],
product: [Array, Array],
- first: [Enumerable, [nil, Fixnum]],
- last: [Enumerable, [nil, Fixnum]],
+ first: [[ActiveRecord::Relation, Enumerable], [nil, Fixnum]],
+ last: [[ActiveRecord::Relation, Enumerable], [nil, Fixnum]],
intersection: [Set, Enumerable],
union: [Set, Enumerable],
keys: [Hash],
values: [Hash],
@@ -255,10 +259,11 @@
end
}
raise "bad arg #{i}, method #{method}: #{ai}/#{ai.class} #{s}" if !ok
}
- obj.send(msg, *args).freeze
+ res = obj.send(msg, *args)
+ ActiveRecord::Relation === res ? res : res.freeze
end
######################################################################
end
end