lib/flippeur.rb in flippeur-0.0.1 vs lib/flippeur.rb in flippeur-1.0.0
- old
+ new
@@ -1,5 +1,32 @@
+require 'flippeur/railtie' if defined?(Rails)
+require 'flippeur/feature'
require "flippeur/version"
module Flippeur
- # Your code goes here...
+
+ UnknownFeature = Class.new RuntimeError
+
+ def self.setup(&block)
+ reset
+ module_eval &block
+ end
+
+ def self.feature(name, &block)
+ features[name] = Feature.new(name, &block)
+ end
+
+ def self.find(name)
+ features[name]
+ end
+
+ private
+
+ def self.features
+ @features ||= Hash.new { |_,k| raise UnknownFeature, "Unknown feature: #{k}" }
+ end
+
+ def self.reset
+ @features = nil
+ end
+
end