Skip to content
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

allow threshold argument to passes_threshold? to enable re-use in subclasses #102

Merged
merged 2 commits into from Dec 6, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 3 additions & 5 deletions lib/arturo/feature.rb
Expand Up @@ -55,7 +55,7 @@ def enabled_for?(feature_recipient)
return false if feature_recipient.nil?
return false if blacklisted?(feature_recipient)
return true if whitelisted?(feature_recipient)
passes_threshold?(feature_recipient)
passes_threshold?(feature_recipient, deployment_percentage || 0)
end

def name
Expand All @@ -79,10 +79,8 @@ def self.last_updated_at
maximum(:updated_at)
end

protected

def passes_threshold?(feature_recipient)
threshold = self.deployment_percentage || 0
# made public so as to allow for thresholds stored outside of the model
def passes_threshold?(feature_recipient, threshold)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a test that shows this usage ... or some docs why this is here would be nice

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not a public interface, so a test feels inappropriate. What are you concretely asking for?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... at least docs would be nice ... # used by external library, do not modify interface
also means we are using a protected method ... making it public might be more obvious ... but either way is fine

return true if threshold == 100
return false if threshold == 0 || !feature_recipient.id
(((feature_recipient.id + (self.id || 1) + 17) * 13) % 100) < threshold
Expand Down