Sha256: e4eb7b364aec076e64dbfbd8679917050c193fad7dd922152f72d8afb43f97b1

Contents?: true

Size: 511 Bytes

Versions: 7

Compression:

Stored size: 511 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

    ActiveRecord::Base.extend(self)

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
edge_rider-2.3.0 lib/edge_rider/collect_column.rb
edge_rider-2.2.0 lib/edge_rider/collect_column.rb
edge_rider-2.1.1 lib/edge_rider/collect_column.rb
edge_rider-2.1.0 lib/edge_rider/collect_column.rb
edge_rider-2.0.0 lib/edge_rider/collect_column.rb
edge_rider-1.1.0 lib/edge_rider/collect_column.rb
edge_rider-1.0.0 lib/edge_rider/collect_column.rb