Sha256: a42357feec67304266223249a81374358cebf1832858bd3b856980d97a4ca59c

Contents?: true

Size: 554 Bytes

Versions: 1

Compression:

Stored size: 554 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)

      scope = scoped({})
      if distinct
        if ActiveRecord::VERSION::MAJOR < 5
          scope = scope.uniq
        else
          scope = scope.distinct
        end
      end
      scope.pluck(qualified_column_name)
    end

  end
end

ActiveSupport.on_load :active_record do
  extend(EdgeRider::CollectColumn)
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
edge_rider-2.3.1 lib/edge_rider/collect_column.rb