Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kristian Mandrup
committed
Nov 28, 2011
1 parent
c23fac9
commit d6d2eb8
Showing
14 changed files
with
111 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
module CanTango | ||
class Configuration | ||
class System < RoleRegistry | ||
include Singleton | ||
|
||
def system= name | ||
raise ArgumentError, "Must be a label" if !name.kind_of_label? | ||
@system = name.to_sym | ||
end | ||
|
||
def system_apis= system_apis | ||
raise ArgumentError, "Must be a hash fx :troles => :role_list, was: #{system_apis}" if !system_apis.kind_of?(Hash) | ||
@system_apis = system_apis | ||
end | ||
|
||
def system | ||
@system ||= default_system | ||
end | ||
|
||
def default_system | ||
nil | ||
end | ||
|
||
def add_systems system_apis | ||
raise ArgumentError, "Must be a hash fx :troles => :role_list, was: #{system_apis}" if !system_apis.kind_of?(Hash) | ||
self.system_apis.merge! system_apis | ||
end | ||
alias_method :add_system, :add_systems | ||
|
||
def system_api | ||
system_apis[system] || {} | ||
end | ||
|
||
def system_apis | ||
@system_apis ||= default_system_apis | ||
end | ||
|
||
def default_system_apis | ||
{} | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
require 'cantango/configuration/shared/role_registry_ex' | ||
|
||
shared_examples_for 'System' do | ||
it_should_behave_like "Role Registry" | ||
|
||
describe 'system' do | ||
its(:system) { should == nil } | ||
|
||
decribe 'system=' do | ||
before do | ||
system = :my_sys | ||
end | ||
its(:system) { should == :my_sys } | ||
end | ||
end | ||
end |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
require 'spec_helper' | ||
require 'cantango/configuration/role_registry_ex' | ||
|
||
class Subject | ||
end | ||
|
||
describe CanTango::Helpers::Role do | ||
before do | ||
CanTango.config.roles.system = :troles | ||
end | ||
|
||
subject do | ||
Subject.new | ||
end | ||
|
||
specify do | ||
subject.role_method(:has).should == :has_role? | ||
end | ||
|
||
specify do | ||
subject.role_method(:list).should == :role_list? | ||
end | ||
end | ||
|
||
|
||
|