-
Notifications
You must be signed in to change notification settings - Fork 3
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
Helpers #21
Helpers #21
Conversation
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.
@sethjeffery
Awesome, I wanted this feature!
But just to confirm, are there any differences between a method defined by helper
and one defined by basic def
?
Yes the main difference is that Modules included with |
Oh, that's dangerous... require 'flagship'
Flagship.define :a do
def foo(c)
puts "foo is called"
true
end
end
Flagship.define :b do
enable :feature, if: ->(c) { foo(c) }
end
Flagship.select_flagset(:b)
p Flagship.enabled?(:feature)
|
Hmm you're right! I actually had originally written to use |
Maybe by this change? Then I think we don't need |
Ok I'll remove the keyword. |
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.
LGTM!
Thank you!
I'll release this with one more change later today. |
From the README...
Helper methods
You can define helpers with the
helper
keyword. Helpers can be used within blocks, procs, or as symbolic names for if statements to tidy up your code.To share helpers, you can simply include them as modules.