Skip to content

Commit

Permalink
Pass SymbolDefs to plugin on_accessor
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandre Terrasa <[email protected]>
  • Loading branch information
Morriar committed Jun 20, 2024
1 parent 122ea20 commit 45bfaf1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions lib/spoom/deadcode/plugins/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,20 +135,20 @@ def save_names_and_patterns(names, names_variable, patterns_variable)
#
# ~~~rb
# class MyPlugin < Spoom::Deadcode::Plugins::Base
# def on_define_accessor(indexer, definition)
# definition.ignored! if definition.name == "foo"
# def on_define_accessor(symbol_def, definition)
# definition.ignored! if symbol_def.name == "foo"
# end
# end
# ~~~
sig { params(indexer: Indexer, definition: Definition).void }
def on_define_accessor(indexer, definition)
sig { params(symbol_def: Model::Attr, definition: Definition).void }
def on_define_accessor(symbol_def, definition)
# no-op
end

# Do not override this method, use `on_define_accessor` instead.
sig { params(indexer: Indexer, definition: Definition).void }
def internal_on_define_accessor(indexer, definition)
on_define_accessor(indexer, definition)
sig { params(symbol_def: Model::Attr, definition: Definition).void }
def internal_on_define_accessor(symbol_def, definition)
on_define_accessor(symbol_def, definition)
end

# Called when a class is defined.
Expand Down
4 changes: 2 additions & 2 deletions test/spoom/deadcode/plugins/base_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class BaseTest < TestWithProject

def test_on_define_accessor
plugin = Class.new(Base) do
def on_define_accessor(indexer, definition)
definition.ignored! if definition.name == "attr_reader1"
def on_define_accessor(symbol_def, definition)
definition.ignored! if symbol_def.name == "attr_reader1"
end
end

Expand Down

0 comments on commit 45bfaf1

Please sign in to comment.