cinchrb / cinch

The IRC Bot Building Framework
http://www.rubydoc.info/gems/cinch
MIT License
1k stars 180 forks source link

Allow Bot#configure to pass arguments through to its block. #206

Closed brpeterman closed 8 years ago

brpeterman commented 8 years ago

This is handy if you want to enclose some data when calling #configure. For example, if your program's config object just happens to be named "@config", you can pass it as an argument to configure to bind it to a new name in the scope of the block.

dominikh commented 8 years ago

I'm not sure I see the use of this. Even with your change, this wouldn't work:

bot = Cinch::Bot.new do
  configure(@config) do |c, config|
  end
end

because inside the first block, @config already refers to that of the Bot, not yours.

Instead, you could do something like this, which doesn't require a new API:

bot = Cinch::Bot.new
bot.configure do |c|
  # @config is my config object, not that of the bot
end

I regret having added #configure in the first place, I'd prefer not to add more to its API if possible.

brpeterman commented 8 years ago

Oh, you're absolutely right. I was trying to solve a problem that I no longer had.

For this to work, we'd need to bind the data in Bot.new. Seems like a pretty worthless change.