Skip to content

Conversation

@djberg96
Copy link
Owner

@djberg96 djberg96 commented Jul 9, 2025

This PR is largely courtesy of AI. It uses TracePoint in order to defer method declaration validation so that you can make interface declarations at the top of a class like any other module instead of having to define interface methods.

# Sample
require 'interface'

MyInterface = interface do
  required_methods :foo, :bar
end

# Before
class MyClass
  def foo
    puts "foo"
  end

  def bar
    puts "bar"
  end

  # Before you had to define them before implementing the interface
  implements MyInterface
end

# After
class MyClass
  implements MyInterface # AI Magic

  def foo
    puts "foo"
  end

  def bar
    puts "bar"
  end
end

@djberg96 djberg96 merged commit 103437d into main Jul 9, 2025
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants