Sha256: 2e3cd1af3f842b207169eadd70573279c624d658e6847bcae6e5e4fa43356178
Contents?: true
Size: 715 Bytes
Versions: 3
Compression:
Stored size: 715 Bytes
Contents
# Database backed system-wide module Flip class DatabaseStrategy < AbstractStrategy def initialize(model_klass = Feature) @klass = model_klass end def description "Database backed, applies to all users." end def knows? definition !!feature(definition) end def on? definition feature(definition).enabled? end def switchable? true end def switch! key, enable @klass.find_or_initialize_by_key(key.to_s).update_attributes! enabled: enable end def delete! key @klass.find_by_key(key.to_s).try(:destroy) end private def feature(definition) @klass.find_by_key definition.key.to_s end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
flip_fork-0.2.0 | lib/flip/database_strategy.rb |
flip_fork-0.1.1 | lib/flip/database_strategy.rb |
flip_fork-0.1.0 | lib/flip/database_strategy.rb |