Sha256: 35af4684b325a4ea7119ab4cb8f8423d424d0c09e7063e5876a3acda251e3a95
Contents?: true
Size: 740 Bytes
Versions: 1
Compression:
Stored size: 740 Bytes
Contents
require 'cookie_flag/unavailable_error' module CookieFlag module Helper extend ActiveSupport::Concern included do helper_method :feature_available? end module ClassMethods def feature(feature_name) before_action -> { unless feature_available?(feature_name) raise UnavailableError end } end end private def feature_available?(feature_name) feature_flags[feature_name].present? && cookies.has_key?(feature_name) && cookies[feature_name] == feature_flags[feature_name] end def feature_flags @feature_flags ||= Rails.application.config_for(CookieFlag.config.name).with_indifferent_access end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cookie_flag-0.1.0 | lib/cookie_flag/helper.rb |