Module: Foobara::Domain
- Defined in:
- foobara-0.0.110/projects/domain/src/domain.rb,
foobara-0.0.110/projects/domain/lib/foobara/domain.rb,
foobara-0.0.110/projects/domain/src/module_extension.rb,
foobara-0.0.110/projects/domain/src/domain_module_extension.rb,
foobara-0.0.110/projects/domain/src/organization_module_extension.rb
Defined Under Namespace
Modules: DomainModuleExtension, ModuleExtension, OrganizationModuleExtension
Classes: AlreadyRegisteredError, CannotSetTypeConstantError, DomainAlreadyExistsError, NoSuchDomain
Class Method Summary
collapse
Class Method Details
.create(full_domain_name) ⇒ Object
.current ⇒ Object
79
80
81
|
# File 'foobara-0.0.110/projects/domain/src/domain.rb', line 79
def current
to_domain(Namespace.current)
end
|
.domain_through_modules(mod) ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'foobara-0.0.110/projects/domain/src/domain.rb', line 39
def domain_through_modules(mod)
mod = Util.module_for(mod)
while mod
if mod.foobara_domain?
namespace = mod
break
end
mod = Util.module_for(mod)
end
if namespace&.foobara_domain?
namespace
else
GlobalDomain
end
end
|
.foobara_type_from_declaration(scoped, type_declaration) ⇒ Object
73
74
75
76
77
|
# File 'foobara-0.0.110/projects/domain/src/domain.rb', line 73
def foobara_type_from_declaration(scoped, type_declaration)
domain = to_domain(scoped)
domain.foobara_type_from_declaration(type_declaration)
end
|
.global ⇒ Object
8
9
10
|
# File 'foobara-0.0.110/projects/domain/src/domain_module_extension.rb', line 8
def global
GlobalDomain
end
|
.install! ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
15
16
|
# File 'foobara-0.0.110/projects/domain/lib/foobara/domain.rb', line 4
def install!
if @installed
raise "Already registered Domain"
end
@installed = true
Namespace.global.foobara_add_category(:organization) { is_a?(Module) && foobara_organization? }
Namespace.global.foobara_add_category(:domain) { is_a?(Module) && foobara_domain? }
end
|
.to_domain(object) ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'foobara-0.0.110/projects/domain/src/domain.rb', line 6
def to_domain(object)
case object
when nil
global
when ::String, ::Symbol
domain = Namespace.global.foobara_lookup_domain(object)
unless domain
raise NoSuchDomain, "Couldn't determine domain for #{object}"
end
domain
when Foobara::Scoped
if object.is_a?(Module) && object.foobara_domain?
object
else
parent = object.scoped_namespace
if parent
to_domain(parent)
else
GlobalDomain
end
end
else
raise NoSuchDomain, "Couldn't determine domain for #{object}"
end
end
|