Sha256: e14617c3e47a0353ffdae209d00d0e0af0e2a33006010da3579b466030d3d16e
Contents?: true
Size: 1.08 KB
Versions: 1
Compression:
Stored size: 1.08 KB
Contents
require "singleton" require "enabler/version" require "enabler/config" require "enabler/storage/redis" require "enabler/errors/rule_already_defined_error" require "enabler/rule" module Enabler class << self def store config.store end def enable!(feature, object) store.add!(feature, object) config.after_enablings[feature].call(object) if config.after_enablings[feature] end def disable!(feature, object) store.remove!(feature, object) config.after_disablings[feature].call(object) if config.after_disablings[feature] end def enabled?(feature, object) enabled_via_rule?(feature, object) || enabled_via_storage?(feature, object) end def config Enabler::Config.instance end def configure(&block) config.instance_eval &block end private def enabled_via_storage?(feature, object) store.enabled?(feature, object) end def enabled_via_rule?(feature, object) Array(Rule.find(feature.to_sym)).map do |r| r.enabled? object end.include? true end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
enabler-0.0.5 | lib/enabler.rb |