Module: Foobara::Scoped
Defined Under Namespace
Classes: NoScopedPathSetError
Instance Attribute Summary collapse
Instance Method Summary
collapse
Instance Attribute Details
#foobara_manifest_reference ⇒ Object
80
81
82
|
# File 'foobara-0.0.110/projects/namespace/src/scoped.rb', line 80
def foobara_manifest_reference
@foobara_manifest_reference ||= scoped_full_name
end
|
#scoped_namespace ⇒ Object
Returns the value of attribute scoped_namespace.
5
6
7
|
# File 'foobara-0.0.110/projects/namespace/src/scoped.rb', line 5
def scoped_namespace
@scoped_namespace
end
|
Instance Method Details
#scoped_absolute_name ⇒ Object
84
85
86
|
# File 'foobara-0.0.110/projects/namespace/src/scoped.rb', line 84
def scoped_absolute_name
@scoped_absolute_name ||= "::#{scoped_full_name}"
end
|
#scoped_category ⇒ Object
109
110
111
|
# File 'foobara-0.0.110/projects/namespace/src/scoped.rb', line 109
def scoped_category
@scoped_category ||= Namespace.global.foobara_category_symbol_for(self)
end
|
#scoped_clear_caches ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
|
# File 'foobara-0.0.110/projects/namespace/src/scoped.rb', line 23
def scoped_clear_caches
[
"@scoped_absolute_name",
"@scoped_name",
"@scoped_prefix",
"@scoped_full_name",
"@scoped_full_path"
].each do |variable|
remove_instance_variable(variable) if instance_variable_defined?(variable)
end
end
|
#scoped_full_name ⇒ Object
74
75
76
|
# File 'foobara-0.0.110/projects/namespace/src/scoped.rb', line 74
def scoped_full_name
@scoped_full_name ||= scoped_full_path.join("::")
end
|
#scoped_full_path ⇒ Object
70
71
72
|
# File 'foobara-0.0.110/projects/namespace/src/scoped.rb', line 70
def scoped_full_path
@scoped_full_path ||= [*scoped_namespace&.scoped_full_path, *scoped_path]
end
|
#scoped_ignore_module?(mod) ⇒ Boolean
100
101
102
|
# File 'foobara-0.0.110/projects/namespace/src/scoped.rb', line 100
def scoped_ignore_module?(mod)
@scoped_ignore_modules&.include?(mod) || scoped_namespace&.scoped_ignore_module?(mod)
end
|
#scoped_ignore_modules=(modules) ⇒ Object
104
105
106
107
|
# File 'foobara-0.0.110/projects/namespace/src/scoped.rb', line 104
def scoped_ignore_modules=(modules)
mods = @scoped_ignore_modules || []
@scoped_ignore_modules = [*mods, *modules]
end
|
#scoped_name ⇒ Object
62
63
64
65
66
67
68
|
# File 'foobara-0.0.110/projects/namespace/src/scoped.rb', line 62
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
35
36
37
38
|
# File 'foobara-0.0.110/projects/namespace/src/scoped.rb', line 35
def scoped_name=(name)
name = name.to_s if name.is_a?(::Symbol)
self.scoped_path = name.split("::")
end
|
#scoped_path ⇒ Object
7
8
9
10
11
12
13
14
15
|
# File 'foobara-0.0.110/projects/namespace/src/scoped.rb', line 7
def scoped_path
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
40
41
42
43
44
|
# File 'foobara-0.0.110/projects/namespace/src/scoped.rb', line 40
def scoped_path=(path)
scoped_clear_caches
@scoped_path = path.map(&:to_s)
end
|
#scoped_path_autoset=(bool) ⇒ Object
46
47
48
|
# File 'foobara-0.0.110/projects/namespace/src/scoped.rb', line 46
def scoped_path_autoset=(bool)
@scoped_path_autoset = bool
end
|
#scoped_path_autoset? ⇒ Boolean
50
51
52
|
# File 'foobara-0.0.110/projects/namespace/src/scoped.rb', line 50
def scoped_path_autoset?
@scoped_path_autoset
end
|
#scoped_path_set? ⇒ Boolean
96
97
98
|
# File 'foobara-0.0.110/projects/namespace/src/scoped.rb', line 96
def scoped_path_set?
defined?(@scoped_path)
end
|
#scoped_prefix ⇒ Object
88
89
90
91
92
93
94
|
# File 'foobara-0.0.110/projects/namespace/src/scoped.rb', line 88
def scoped_prefix
return @scoped_prefix if defined?(@scoped_prefix)
@scoped_prefix = unless scoped_path.size == 1
scoped_path[0..-2]
end
end
|
#scoped_short_name ⇒ Object
54
55
56
|
# File 'foobara-0.0.110/projects/namespace/src/scoped.rb', line 54
def scoped_short_name
@scoped_short_name ||= scoped_path.last
end
|
#scoped_short_path ⇒ Object
58
59
60
|
# File 'foobara-0.0.110/projects/namespace/src/scoped.rb', line 58
def scoped_short_path
@scoped_short_path ||= [scoped_short_name]
end
|