mirror of https://github.com/rails/rails
Add examples to #slice and #values_at documentation [ci-skip] (#50679)
This commit is contained in:
parent
90d0dc5961
commit
8944d804ec
|
@ -52,6 +52,10 @@ module ActiveModel
|
|||
# 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.
|
||||
|
||||
|
@ -62,6 +66,10 @@ module ActiveModel
|
|||
#
|
||||
# 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
|
||||
|
|
|
@ -569,6 +569,10 @@ module ActiveRecord
|
|||
# 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.
|
||||
|
||||
|
@ -579,6 +583,10 @@ module ActiveRecord
|
|||
#
|
||||
# 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.
|
||||
|
||||
|
|
Loading…
Reference in New Issue