File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed
activemodel/lib/active_model
activerecord/lib/active_record Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -52,6 +52,10 @@ module Model
52
52
# Returns a hash of the given methods with their names as keys and returned
53
53
# values as values.
54
54
#
55
+ # person = Person.new(id: 1, name: "bob")
56
+ # person.slice(:id, :name)
57
+ # => { "id" => 1, "name" => "bob" }
58
+ #
55
59
#--
56
60
# Implemented by ActiveModel::Access#slice.
57
61
@@ -62,6 +66,10 @@ module Model
62
66
#
63
67
# Returns an array of the values returned by the given methods.
64
68
#
69
+ # person = Person.new(id: 1, name: "bob")
70
+ # person.values_at(:id, :name)
71
+ # => [1, "bob"]
72
+ #
65
73
#--
66
74
# Implemented by ActiveModel::Access#values_at.
67
75
end
Original file line number Diff line number Diff line change @@ -569,6 +569,10 @@ def encode_with(coder)
569
569
# Returns a hash of the given methods with their names as keys and returned
570
570
# values as values.
571
571
#
572
+ # topic = Topic.new(title: "Budget", author_name: "Jason")
573
+ # topic.slice(:title, :author_name)
574
+ # => { "title" => "Budget", "author_name" => "Jason" }
575
+ #
572
576
#--
573
577
# Implemented by ActiveModel::Access#slice.
574
578
@@ -579,6 +583,10 @@ def encode_with(coder)
579
583
#
580
584
# Returns an array of the values returned by the given methods.
581
585
#
586
+ # topic = Topic.new(title: "Budget", author_name: "Jason")
587
+ # topic.values_at(:title, :author_name)
588
+ # => ["Budget", "Jason"]
589
+ #
582
590
#--
583
591
# Implemented by ActiveModel::Access#values_at.
584
592
You can’t perform that action at this time.
0 commit comments