Sha256: 146c2b1183c1112eae21ba964008d855980cdda0cb0b74b63d73063366db7ac7
Contents?: true
Size: 602 Bytes
Versions: 3
Compression:
Stored size: 602 Bytes
Contents
# frozen_string_literal: true require 'deep_pluck/version' require 'deep_pluck/model' require 'active_record' require 'pluck_all' class ActiveRecord::Relation def deep_pluck(*args) DeepPluck::Model.new(self).add(args).load_all end end class ActiveRecord::Base def self.deep_pluck(*args) where('').deep_pluck(*args) end 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 end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
deep_pluck-1.3.2 | lib/deep_pluck.rb |
deep_pluck-1.3.1 | lib/deep_pluck.rb |
deep_pluck-1.3.0 | lib/deep_pluck.rb |