Skip to content

Commit

Permalink
activemodel: signature updates (#739)
Browse files Browse the repository at this point in the history
* activemodel: update `register` signature to use an optional block

* activemodel: update `delete` signature to include optional type and options parameters for 7.0/7.1
  • Loading branch information
hjwylde authored Dec 13, 2024
1 parent 7ad9c0f commit 400a2ec
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 10 deletions.
10 changes: 10 additions & 0 deletions gems/activemodel/6.0/activemodel-6.0.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module ActiveModel
class Errors
# Delete messages for +key+. Returns the deleted messages.
#
# person.errors[:name] # => ["cannot be nil"]
# person.errors.delete(:name) # => ["cannot be nil"]
# person.errors[:name] # => []
def delete: (untyped key) -> untyped
end
end
10 changes: 0 additions & 10 deletions gems/activemodel/6.0/activemodel-generated.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -1411,13 +1411,6 @@ module ActiveModel

alias key? include?

# Delete messages for +key+. Returns the deleted messages.
#
# person.errors[:name] # => ["cannot be nil"]
# person.errors.delete(:name) # => ["cannot be nil"]
# person.errors[:name] # => []
def delete: (untyped key) -> untyped

# When passed a symbol or a name of a method, returns an array of errors
# for the method.
#
Expand Down Expand Up @@ -2901,9 +2894,6 @@ module ActiveModel
module Type
attr_accessor self.registry: untyped

# Add a new type to the registry, allowing it to be gotten through ActiveModel::Type#lookup
def self.register: (untyped type_name, ?untyped? klass, **untyped options) { () -> untyped } -> untyped

def self.lookup: (*untyped args, **untyped kwargs) -> untyped

def self.default_value: () -> untyped
Expand Down
7 changes: 7 additions & 0 deletions gems/activemodel/6.0/activemodel.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,13 @@ module ActiveModel
end
end

module ActiveModel
module Type
# Add a new type to the registry, allowing it to be gotten through ActiveModel::Type#lookup
def self.register: (untyped type_name, ?untyped? klass, **untyped options) ?{ () -> untyped } -> untyped
end
end

module ActiveModel
module Validations
module ClassMethods
Expand Down
11 changes: 11 additions & 0 deletions gems/activemodel/7.0/activemodel-7.0.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,14 @@ module ActiveModel
def strict_match?: (Symbol | String attribute, (Symbol | String)? type, **untyped options) -> bool
end
end

module ActiveModel
class Errors
# Delete messages for +key+. Returns the deleted messages.
#
# person.errors[:name] # => ["cannot be nil"]
# person.errors.delete(:name) # => ["cannot be nil"]
# person.errors[:name] # => []
def delete: (untyped key, ?untyped type, **untyped) -> untyped
end
end
11 changes: 11 additions & 0 deletions gems/activemodel/7.1/activemodel-7.1.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,17 @@ module ActiveModel
end
end

module ActiveModel
class Errors
# Delete messages for +key+. Returns the deleted messages.
#
# person.errors[:name] # => ["cannot be nil"]
# person.errors.delete(:name) # => ["cannot be nil"]
# person.errors[:name] # => []
def delete: (untyped key, ?untyped type, **untyped) -> untyped
end
end

module ActiveModel
module Model
include ActiveModel::Access
Expand Down

0 comments on commit 400a2ec

Please sign in to comment.