Skip to content

Commit

Permalink
Merge pull request #465 from m11o/feature/add-types-attr-internal-met…
Browse files Browse the repository at this point in the history
…hods

Add types for `attr_internal_**` methods
  • Loading branch information
pocke authored Jan 25, 2024
2 parents e9d3173 + 18e6755 commit 6fa47a8
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 22 deletions.
9 changes: 9 additions & 0 deletions gems/activesupport/6.0/_test/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,12 @@

hash.deep_symbolize_keys
hash.deep_symbolize_keys!

class TestAttrInternal
attr_internal_reader :internal_variable_reader_1
attr_internal_reader 'internal_variable_reader_2', :internal_variable_reader_3
attr_internal_writer :internal_variable_writer_1
attr_internal_writer 'internal_variable_writer_2'
attr_internal_writer :internal_variable_accessor_1
attr_internal_writer 'internal_variable_accessor_2'
end
2 changes: 2 additions & 0 deletions gems/activesupport/6.0/_test/test.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class TestAttrInternal
end
22 changes: 0 additions & 22 deletions gems/activesupport/6.0/activesupport-generated.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -3510,28 +3510,6 @@ class Module
def anonymous?: () -> untyped
end

class Module
# Declares an attribute reader backed by an internally-named instance variable.
def attr_internal_reader: (*untyped attrs) -> untyped

# Declares an attribute writer backed by an internally-named instance variable.
def attr_internal_writer: (*untyped attrs) -> untyped

# Declares an attribute reader and writer backed by an internally-named instance
# variable.
def attr_internal_accessor: (*untyped attrs) -> untyped

alias attr_internal attr_internal_accessor

attr_accessor self.attr_internal_naming_format: untyped

private

def attr_internal_ivar_name: (untyped attr) -> untyped

def attr_internal_define: (untyped attr_name, untyped `type`) -> untyped
end

# Extends the module object with class/module and instance accessors for
# class/module attributes, just like the native attr* accessors for instance
# attributes.
Expand Down
22 changes: 22 additions & 0 deletions gems/activesupport/6.0/activesupport.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,28 @@ class Module
# Manual definition to make block optional
def mattr_accessor: (*untyped syms, ?default: untyped? default, ?instance_accessor: bool instance_accessor, ?instance_writer: bool instance_writer, ?instance_reader: bool instance_reader) ?{ () -> untyped } -> untyped
| ...

# TODO: Fix to use `interned` in attrs params after releasing ruby/rbs#1499
def attr_internal_reader: (*(Symbol | String) attrs) -> void

# TODO: Fix to use `interned` in attrs params after releasing ruby/rbs#1499
def attr_internal_writer: (*(Symbol | String) attrs) -> void

# TODO: Fix to use `interned` in attrs params after releasing ruby/rbs#1499
def attr_internal_accessor: (*(Symbol | String) attrs) -> void

alias attr_internal attr_internal_accessor

attr_accessor self.attr_internal_naming_format: String

private

# TODO: Fix to use `interned` in attr params after releasing ruby/rbs#1499
def attr_internal_ivar_name: ((Symbol | String) attr) -> String

type access_type = :reader | :writer
# TODO: Fix to use `interned` in attr params after releasing ruby/rbs#1499
def attr_internal_define: ((Symbol | String) attr_name, access_type `type`) -> void
end

class Integer
Expand Down

0 comments on commit 6fa47a8

Please sign in to comment.