-
Notifications
You must be signed in to change notification settings - Fork 211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set correct configuration method name and add tests #19
Conversation
a42dac1
to
07eeae1
Compare
Nice, @gauravtiwari! Two things, though: 1: This pull request has two different things in it, so it should be two pull requests; one for Rack 2.0, and one for the configuration block. 2: I like that you can configure without a block now! I don't think it makes as much sense to read configuration values with Also, thanks for adding tests! |
Actually, no, # Conventional, reads well
Facebook::Messenger.configure do |config|
config.access_token = '...'
end
# Unconventional, doesn't read well because it's not a verb and you're changing something
Facebook::Messenger.configuration do |config|
config.access_token = '...'
end
# Conventional, reads well
Facebook::Messenger.configuration.access_token = '...'
# Unconventional, but still reads pretty well because it's a verb and you're changing something
Facebook::Messenger.configure.access_token = '...'
# Unconventional, doesn't read well because it's a verb and you're not changing anything
Facebook::Messenger.configure.access_token # => '...' |
@jgorset Yup, I thought so when making a PR, but may be forgot along the way. I will revert the rack change and make two pull requests. Yes makes sense. Should I add another method for module |
I guess |
@jgorset Sure thing, |
Leave the tests, though! I messed that. 😁 |
Will do 👍 |
@jgorset You tried this: https://github.com/hyperoslo/facebook-messenger-demo, basically here you have to message: https://www.facebook.com/chatbotmessenger/ (added you as a tester) |
Fix wordings Fix quotes Test yield configuration Fix syntax Fix rubocop offenses Fix tests Refactor tests Fix rubocop offense Use configure
@jgorset Guess this is it for this PR? |
Why not leave #configure? It's very clear IMO and it doesn't break compatibility. Rails does the same: https://github.com/rails/rails/blob/04ad814bb992e854927c1bec3422df882f017ab6/activesupport/lib/active_support/configurable.rb#L36 PD: I will only leave #configure in the README, and leave #config for advanced users. |
@frodsan is right, of course – |
when @request.get? then verify | ||
when @request.post? then receive | ||
if @request.get? then verify | ||
elsif @request.post? then receive |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer case
to elsif
in general, but especially if there's a chance there might be more conditions down the road. I couldn't find anything on this in bbatsov/ruby-style-guide, though – what do you think, @hyperoslo/web?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jgorset Code wise, they both look the same except the extra case statement, same for readability. Rubocop
now, doesn't like case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed it doesn't! It doesn't like empty case
statements at all. I yield, then!
If you revert to |
@jgorset All reverted already 😄 |
Ohh wait! config |
@jgorset Just take a look once if all looks good 😃 |
Facebook::Messenger.config.verify_token | ||
# => my_voice_is_my_password_verify_me | ||
``` | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure that we need this since the configuration is really only used internally, but we can remove it later.
Looks good! Nice job! |
No description provided.