class ActiveRecord::Base

Public Class Methods

deep_pluck(*args) click to toggle source
# File lib/deep_pluck.rb, line 13
def self.deep_pluck(*args)
  where('').deep_pluck(*args)
end

Public Instance Methods

deep_pluck(*args) click to toggle source
# File lib/deep_pluck.rb, line 17
def deep_pluck(*args)
  hash_args, other_args = args.partition{|s| s.is_a?(Hash) }
  model = DeepPluck::Model.new(self, need_columns: other_args)
  model.add(*hash_args) if hash_args.any?
  return model.load_all.first
end