Skip to content

Instantly share code, notes, and snippets.

@nathancarnes
Created February 10, 2015 00:25
Show Gist options
  • Save nathancarnes/9cb9e3cf21dccace3a2e to your computer and use it in GitHub Desktop.
Save nathancarnes/9cb9e3cf21dccace3a2e to your computer and use it in GitHub Desktop.
An amazing library for feature flags in Rails
# Just put this into lib/, and add your methods!
# Usage: Features.your_feature_name?
class Features
# Admin-only features? We've got that!
def self.reticulate_splines?
current_user && current_user.admin?
end
# Don't want to deploy to flip it on or off? It supports that!
def self.release_the_hounds?
ENV['RELEASE_THE_HOUNDS'].present?
end
# Whoa whoa whoa. What about time-based releases? YUP!
def self.be_awesome?
Time.current < Time.new(2525, 01, 01)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment