Class: ConfigCore::ScopesCollection
- Inherits:
-
Object
- Object
- ConfigCore::ScopesCollection
- Defined in:
- lib/config_core/scopes_collection.rb
Instance Method Summary collapse
- #[](name) ⇒ Object
- #define(name) {|scope| ... } ⇒ Object
- #has_scope?(name) ⇒ Boolean
-
#initialize ⇒ ScopesCollection
constructor
A new instance of ScopesCollection.
- #to_h ⇒ Object
Constructor Details
#initialize ⇒ ScopesCollection
Returns a new instance of ScopesCollection.
3 4 5 |
# File 'lib/config_core/scopes_collection.rb', line 3 def initialize @scopes = {} end |
Instance Method Details
#[](name) ⇒ Object
11 12 13 |
# File 'lib/config_core/scopes_collection.rb', line 11 def [](name) @scopes[name] end |
#define(name) {|scope| ... } ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/config_core/scopes_collection.rb', line 19 def define(name) raise ScopeAlreadyExistsError if has_scope?(name) scope = Scope.new(name) yield(scope) if block_given? @scopes[name] = scope define_scope_reader(name, scope) return scope end |
#has_scope?(name) ⇒ Boolean
15 16 17 |
# File 'lib/config_core/scopes_collection.rb', line 15 def has_scope?(name) @scopes.has_key?(name) end |
#to_h ⇒ Object
7 8 9 |
# File 'lib/config_core/scopes_collection.rb', line 7 def to_h @scopes end |