lib/pluck_map/attribute.rb in pluck_map-0.5.0 vs lib/pluck_map/attribute.rb in pluck_map-0.6.0
- old
+ new
@@ -15,18 +15,27 @@
@selects = []
else
raise ArgumentError, "You must select at least one column" if selects.empty?
raise ArgumentError, "You must define a block if you are going to select " <<
"more than one expression from the database" if selects.length > 1 && !block
+
+ @selects = @selects.map do |select|
+ if select.is_a?(String) && !select.is_a?(Arel::Nodes::SqlLiteral)
+ puts "DEPRECATION WARNING: Passing raw SQL as a String to :select is deprecated. Known-safe values can be passed by wrapping them in Arel.sql()."
+ Arel.sql(select)
+ else
+ select
+ end
+ end
end
end
def apply(object)
block.call(*object)
end
- def no_map?
- block.nil?
+ def will_map?
+ !block.nil?
end
# When the PluckMapPresenter performs the query, it will
# receive an array of rows. Each row will itself be an
# array of values.