Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add examples to #slice and #values_at documentation [ci-skip] (#50679) #50736

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions activemodel/lib/active_model/model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ module Model
# Returns a hash of the given methods with their names as keys and returned
# values as values.
#
# person = Person.new(id: 1, name: "bob")
# person.slice(:id, :name)
# => { "id" => 1, "name" => "bob" }
#
#--
# Implemented by ActiveModel::Access#slice.

Expand All @@ -62,6 +66,10 @@ module Model
#
# Returns an array of the values returned by the given methods.
#
# person = Person.new(id: 1, name: "bob")
# person.values_at(:id, :name)
# => [1, "bob"]
#
#--
# Implemented by ActiveModel::Access#values_at.
end
Expand Down
8 changes: 8 additions & 0 deletions activerecord/lib/active_record/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,10 @@ def encode_with(coder)
# Returns a hash of the given methods with their names as keys and returned
# values as values.
#
# topic = Topic.new(title: "Budget", author_name: "Jason")
# topic.slice(:title, :author_name)
# => { "title" => "Budget", "author_name" => "Jason" }
#
#--
# Implemented by ActiveModel::Access#slice.

Expand All @@ -576,6 +580,10 @@ def encode_with(coder)
#
# Returns an array of the values returned by the given methods.
#
# topic = Topic.new(title: "Budget", author_name: "Jason")
# topic.values_at(:title, :author_name)
# => ["Budget", "Jason"]
#
#--
# Implemented by ActiveModel::Access#values_at.

Expand Down