Skip to content

How can I specify context inside block from plugin? #518

Answered by castwide
alisnic asked this question in Q&A
Discussion options

You must be logged in to vote

Solargraph provides a custom @yieldself tag that lets you specify the context of a yielded block. Example:

class Example
  def something
  end
end

# @yieldself [Example]
def run_in_example &block
  Example.new.instance_eval &block
end

run_in_example do
  something # <- Recognized as Example#something
end

The @yieldself tag should work inside an @!override as well.

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@alisnic
Comment options

@alisnic
Comment options

Answer selected by alisnic
Comment options

You must be logged in to vote
1 reply
@alisnic
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants