Module: Foobara::Scoped
Defined Under Namespace
Classes: NoScopedPathSetError
Instance Attribute Summary collapse
Instance Method Summary
collapse
Instance Attribute Details
#foobara_manifest_reference ⇒ Object
90
91
92
93
94
95
96
97
98
99
|
# File 'foobara-0.2.2/projects/namespace/src/scoped.rb', line 90
def foobara_manifest_reference
if scoped_unregistered?
raise "Cannot use unregistered Scoped object"
end
@foobara_manifest_reference ||= scoped_full_name
end
|
#scoped_namespace ⇒ Object
Returns the value of attribute scoped_namespace.
5
6
7
|
# File 'foobara-0.2.2/projects/namespace/src/scoped.rb', line 5
def scoped_namespace
@scoped_namespace
end
|
#unregistered_foobara_manifest_reference ⇒ Object
Returns the value of attribute unregistered_foobara_manifest_reference.
6
7
8
|
# File 'foobara-0.2.2/projects/namespace/src/scoped.rb', line 6
def unregistered_foobara_manifest_reference
@unregistered_foobara_manifest_reference
end
|
Instance Method Details
#scoped_absolute_name ⇒ Object
101
102
103
|
# File 'foobara-0.2.2/projects/namespace/src/scoped.rb', line 101
def scoped_absolute_name
@scoped_absolute_name ||= "::#{scoped_full_name}"
end
|
#scoped_category ⇒ Object
126
127
128
|
# File 'foobara-0.2.2/projects/namespace/src/scoped.rb', line 126
def scoped_category
@scoped_category ||= Namespace.global.foobara_category_symbol_for(self)
end
|
#scoped_clear_caches ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'foobara-0.2.2/projects/namespace/src/scoped.rb', line 31
def scoped_clear_caches
[
:@scoped_absolute_name,
:@scoped_name,
:@scoped_prefix,
:@scoped_full_name,
:@scoped_full_path,
:@scoped_short_name,
:@scoped_short_path
].each do |variable|
remove_instance_variable(variable) if instance_variable_defined?(variable)
end
end
|
#scoped_full_name ⇒ Object
84
85
86
|
# File 'foobara-0.2.2/projects/namespace/src/scoped.rb', line 84
def scoped_full_name
@scoped_full_name ||= scoped_full_path.join("::")
end
|
#scoped_full_path ⇒ Object
80
81
82
|
# File 'foobara-0.2.2/projects/namespace/src/scoped.rb', line 80
def scoped_full_path
@scoped_full_path ||= [*scoped_namespace&.scoped_full_path, *scoped_path]
end
|
#scoped_ignore_module?(mod) ⇒ Boolean
117
118
119
|
# File 'foobara-0.2.2/projects/namespace/src/scoped.rb', line 117
def scoped_ignore_module?(mod)
@scoped_ignore_modules&.include?(mod) || scoped_namespace&.scoped_ignore_module?(mod)
end
|
#scoped_ignore_modules=(modules) ⇒ Object
121
122
123
124
|
# File 'foobara-0.2.2/projects/namespace/src/scoped.rb', line 121
def scoped_ignore_modules=(modules)
mods = @scoped_ignore_modules || []
@scoped_ignore_modules = [*mods, *modules]
end
|
#scoped_name ⇒ Object
72
73
74
75
76
77
78
|
# File 'foobara-0.2.2/projects/namespace/src/scoped.rb', line 72
def scoped_name
return @scoped_name if defined?(@scoped_name)
@scoped_name = unless scoped_path.empty?
scoped_path.join("::")
end
end
|
#scoped_name=(name) ⇒ Object
45
46
47
48
|
# File 'foobara-0.2.2/projects/namespace/src/scoped.rb', line 45
def scoped_name=(name)
name = name.to_s if name.is_a?(::Symbol)
self.scoped_path = name.split("::")
end
|
#scoped_path ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'foobara-0.2.2/projects/namespace/src/scoped.rb', line 8
def scoped_path
if scoped_unregistered?
raise "Cannot use unregistered Scoped object"
end
unless defined?(@scoped_path)
raise NoScopedPathSetError, "No scoped path set. Explicitly set it to nil if that's what you want."
end
@scoped_path
end
|
#scoped_path=(path) ⇒ Object
50
51
52
53
54
|
# File 'foobara-0.2.2/projects/namespace/src/scoped.rb', line 50
def scoped_path=(path)
scoped_clear_caches
@scoped_path = path.map(&:to_s)
end
|
#scoped_path_autoset=(bool) ⇒ Object
56
57
58
|
# File 'foobara-0.2.2/projects/namespace/src/scoped.rb', line 56
def scoped_path_autoset=(bool)
@scoped_path_autoset = bool
end
|
#scoped_path_autoset? ⇒ Boolean
60
61
62
|
# File 'foobara-0.2.2/projects/namespace/src/scoped.rb', line 60
def scoped_path_autoset?
@scoped_path_autoset
end
|
#scoped_path_set? ⇒ Boolean
113
114
115
|
# File 'foobara-0.2.2/projects/namespace/src/scoped.rb', line 113
def scoped_path_set?
defined?(@scoped_path)
end
|
#scoped_prefix ⇒ Object
105
106
107
108
109
110
111
|
# File 'foobara-0.2.2/projects/namespace/src/scoped.rb', line 105
def scoped_prefix
return @scoped_prefix if defined?(@scoped_prefix)
@scoped_prefix = unless scoped_path.size == 1
scoped_path[0..-2]
end
end
|
#scoped_reregistering! ⇒ Object
138
139
140
|
# File 'foobara-0.2.2/projects/namespace/src/scoped.rb', line 138
def scoped_reregistering!
@scoped_unregistered = nil
end
|
#scoped_short_name ⇒ Object
64
65
66
|
# File 'foobara-0.2.2/projects/namespace/src/scoped.rb', line 64
def scoped_short_name
@scoped_short_name ||= scoped_path.last
end
|
#scoped_short_path ⇒ Object
68
69
70
|
# File 'foobara-0.2.2/projects/namespace/src/scoped.rb', line 68
def scoped_short_path
@scoped_short_path ||= [scoped_short_name]
end
|
#scoped_unregistered! ⇒ Object
130
131
132
|
# File 'foobara-0.2.2/projects/namespace/src/scoped.rb', line 130
def scoped_unregistered!
@scoped_unregistered = true
end
|
#scoped_unregistered? ⇒ Boolean
134
135
136
|
# File 'foobara-0.2.2/projects/namespace/src/scoped.rb', line 134
def scoped_unregistered?
@scoped_unregistered
end
|