diff --git a/lib/flop.rb b/lib/flop.rb index a478292..7601d76 100644 --- a/lib/flop.rb +++ b/lib/flop.rb @@ -1,6 +1,8 @@ require 'flop/version' require 'flop/feature' + +require 'flop/repository' require 'flop/repository/memory' require 'flop/repository/redis' diff --git a/lib/flop/repository.rb b/lib/flop/repository.rb new file mode 100644 index 0000000..826fe06 --- /dev/null +++ b/lib/flop/repository.rb @@ -0,0 +1,14 @@ +module Flop + class Repository + def get(name) + raise GetNotImplemented + end + + def set(name, value) + raise SetNotImplemented + end + + GetNotImplemented = Class.new(StandardError) + SetNotImplemented = Class.new(StandardError) + end +end diff --git a/lib/flop/repository/memory.rb b/lib/flop/repository/memory.rb index 88073ea..71e5de5 100644 --- a/lib/flop/repository/memory.rb +++ b/lib/flop/repository/memory.rb @@ -1,6 +1,6 @@ module Flop - module Repository - class Memory + class Repository + class Memory < Flop::Repository def initialize @features = Hash.new(false) end diff --git a/lib/flop/repository/redis.rb b/lib/flop/repository/redis.rb index c56872b..9754c7f 100644 --- a/lib/flop/repository/redis.rb +++ b/lib/flop/repository/redis.rb @@ -1,6 +1,6 @@ module Flop - module Repository - class Redis + class Repository + class Redis < Flop::Repository def initialize(redis, namespace = '') @redis = redis @namespace = namespace diff --git a/test/flop/repository_test.rb b/test/flop/repository_test.rb new file mode 100644 index 0000000..746523b --- /dev/null +++ b/test/flop/repository_test.rb @@ -0,0 +1,19 @@ +require 'test_helper' + +class Flop::RepositoryTest < Minitest::Test + def setup + @repo = Flop::Repository.new + end + + def test_get_raises_exception + assert_raises(Flop::Repository::GetNotImplemented) do + @repo.get(:test) + end + end + + def test_set_raises_exception + assert_raises(Flop::Repository::SetNotImplemented) do + @repo.set(:test, true) + end + end +end