Sha256: 16290724a86fae86c0045eff5aaa8a7fd6fc9f5ea41feb55a54b0c1bf37074d4
Contents?: true
Size: 853 Bytes
Versions: 9
Compression:
Stored size: 853 Bytes
Contents
module EdgeRider module CollectColumn def collect_column(column_name, find_options = {}) distinct = find_options.delete(:distinct) qualified_column_name = EdgeRider::Util.qualify_column_name(self, column_name) if respond_to?(:pluck) # Rails 3.2+ scope = scoped({}) scope = scope.uniq if distinct scope.pluck(qualified_column_name) else # Rails 2 select = distinct ? "DISTINCT #{qualified_column_name}" : qualified_column_name query = scoped(find_options.merge(:select => select)).to_sql raw_values = connection.select_values(query) column = columns_hash[column_name.to_s] or raise "Could not retrieve column information: #{column_name}" raw_values.collect { |value| column.type_cast(value) } end end ActiveRecord::Base.extend(self) end end
Version data entries
9 entries across 9 versions & 1 rubygems