README.md in deep_pluck-1.1.1 vs README.md in deep_pluck-1.1.2

- old
+ new

@@ -6,11 +6,11 @@ [![Code Climate](https://codeclimate.com/github/khiav223577/deep_pluck/badges/gpa.svg)](https://codeclimate.com/github/khiav223577/deep_pluck) [![Test Coverage](https://codeclimate.com/github/khiav223577/deep_pluck/badges/coverage.svg)](https://codeclimate.com/github/khiav223577/deep_pluck/coverage) Allow you to pluck deeply into nested associations without loading a bunch of records. -Support Rails 3.2, 4.2, 5.0, 5.1, 5.2. +Support Rails 3.2, 4.2, 5.0, 5.1, 5.2, 6.0. ## Installation Add this line to your application's Gemfile: @@ -31,35 +31,35 @@ ### Similar to #pluck method ```rb User.deep_pluck(:id, :name) -# SELECT `users`.`id`, `users`.`name` FROM `users` -# => +# SELECT `users`.`id`, `users`.`name` FROM `users` +# => # [ -# {'id' => 1, 'name' => 'David'}, +# {'id' => 1, 'name' => 'David'}, # {'id' => 2, 'name' => 'Jeremy'}, # ] ``` ### Pluck attributes from nested associations ```rb User.deep_pluck(:name, 'posts' => :title) # SELECT `users`.`id`, `users`.`name` FROM `users` # SELECT `posts`.`user_id`, `posts`.`title` FROM `posts` WHERE `posts`.`user_id` IN (1, 2) -# => +# => # [ # { -# 'name' => 'David' , +# 'name' => 'David' , # 'posts' => [ -# {'title' => 'post1'}, +# {'title' => 'post1'}, # {'title' => 'post2'}, # ], -# }, +# }, # { -# 'name' => 'Jeremy', +# 'name' => 'Jeremy', # 'posts' => [ # {'title' => 'post3'}, # ], # }, # ] @@ -70,13 +70,13 @@ ```rb user = User.find_by(name: 'David') user.deep_pluck(:name, :posts => :title) # => # { -# 'name' => 'David' , +# 'name' => 'David' , # :posts => [ -# {'title' => 'post1'}, +# {'title' => 'post1'}, # {'title' => 'post2'}, # ], # } ``` @@ -90,14 +90,14 @@ And the following #as_json example: ```rb User.where(:name => %w(Pearl Kathenrie)).includes([{:posts => :post_comments}, :contact]).as_json({ :root => false, - :only => [:name, :email], + :only => [:name, :email], :include => { 'posts' => { - :only => :name, + :only => :name, :include => { 'post_comments' => { :only => :comment, }, }, @@ -114,12 +114,12 @@ Not to mention the huge performace improvement by using #deep_pluck. You could refactor the example with #deep_pluck: ```rb User.where(:name => %w(Pearl Kathenrie)).deep_pluck( - :name, - :email, - 'posts' => [:name, 'post_comments' => :comment], + :name, + :email, + 'posts' => [:name, 'post_comments' => :comment], 'contact' => :address, ) ``` ### Better Performance