Skip to content
Browse files

using Registr::Base

  • Loading branch information...
1 parent 84dc943 commit 5495e905213b17b49440a9ec9a975d807836c498 Kristian Mandrup committed Nov 28, 2011
View
6 lib/cantango/configuration.rb
@@ -1,5 +1,9 @@
module CanTango
class Configuration
- autoload_modules :RoleGroups, :Roles, :System, :RoleRegistry
+ autoload_modules :RoleGroups, :Roles, :System
+
+ module Registry
+ autoload_modules :Role
+ end
end
end
View
34 lib/cantango/configuration/registry/role.rb
@@ -0,0 +1,34 @@
+module CanTango
+ class Configuration
+ module Registry
+ class Role < Base
+ def only *names
+ @onlies = names.select_labels
+ end
+
+ def onlies
+ @onlies ||= []
+ end
+
+ def excluded
+ @excluded ||= []
+ end
+
+ def exclude *names
+ @excluded = names.select_labels
+ end
+
+ def filter?
+ !(excluded + onlies).empty?
+ end
+
+ def clear!
+ super
+ @excluded = []
+ @onlies = []
+ end
+ end
+ end
+ end
+end
+
View
32 lib/cantango/configuration/role_registry.rb
@@ -1,32 +0,0 @@
-module CanTango
- class Configuration
- class RoleRegistry < Registry
- def only *names
- @onlies = names.select_labels
- end
-
- def onlies
- @onlies ||= []
- end
-
- def excluded
- @excluded ||= []
- end
-
- def exclude *names
- @excluded = names.select_labels
- end
-
- def filter?
- !(excluded + onlies).empty?
- end
-
- def clear!
- super
- @excluded = []
- @onlies = []
- end
- end
- end
-end
-
View
2 lib/cantango/configuration/system.rb
@@ -1,6 +1,6 @@
module CanTango
class Configuration
- class System < RoleRegistry
+ class System < Registry::Role
include Singleton
def system= name
View
9 spec/cantango/configuration/role_registry_spec.rb
@@ -0,0 +1,9 @@
+require 'spec_helper'
+require 'cantango/configuration/shared/role_registry_ex'
+
+describe CanTango::Configuration::Registry::Role do
+ subject { CanTango.config.roles }
+
+ it_should_behave_like "Role Registry" do
+ end
+end

0 comments on commit 5495e90

Please sign in to comment.
Something went wrong with that request. Please try again.