./lib/ambition/processor.rb in ambition-0.1.5 vs ./lib/ambition/processor.rb in ambition-0.1.6
- old
+ new
@@ -43,18 +43,44 @@
def to_s
process(@block.to_sexp).squeeze(' ')
end
def sanitize(value)
- case value.to_s
- when 'true' then '1'
- when 'false' then '0'
- else ActiveRecord::Base.connection.quote(value) rescue quote(value)
+ if value.is_a? Array
+ return value.map { |v| sanitize(v) }.join(', ')
end
+
+ case value
+ when true, 'true'
+ '1'
+ when false, 'false'
+ '0'
+ when Regexp
+ "'#{value.source}'"
+ else
+ ActiveRecord::Base.connection.quote(value)
+ end
+ rescue ActiveRecord::ConnectionNotEstablished
+ quote(value)
+ rescue
+ "'#{value}'"
end
def quote_column_name(value)
- ActiveRecord::Base.connection.quote_column_name(value) rescue value.to_s
+ ActiveRecord::Base.connection.quote_column_name(value)
+ rescue ActiveRecord::ConnectionNotEstablished
+ value.to_s
+ end
+
+ def statement(*args)
+ @statement_instnace ||= DatabaseStatements.const_get(adapter_name).new
+ @statement_instnace.send(*args)
+ end
+
+ def adapter_name
+ ActiveRecord::Base.connection.adapter_name
+ rescue ActiveRecord::ConnectionNotEstablished
+ 'Abstract'
end
def extract_includes(receiver, method)
return unless receiver.first == :call && receiver[1].last == @receiver