Class: ActiveSupport::Dependencies::WatchStack
- Inherits:
-
Array
show all
- Defined in:
- lib/active_support/dependencies.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Array
#as_json, #encode_json, #extract_options!, #fifth, #forty_two, #fourth, #from, #in_groups, #in_groups_of, #sample, #second, #split, #third, #to, #to_formatted_s, #to_param, #to_query, #to_sentence, #to_xml, #uniq_by, #uniq_by!, wrap
Constructor Details
Returns a new instance of WatchStack.
67
68
69
|
# File 'lib/active_support/dependencies.rb', line 67
def initialize
@mutex = Mutex.new
end
|
Class Method Details
.locked(*methods) ⇒ Object
71
72
73
|
# File 'lib/active_support/dependencies.rb', line 71
def self.locked(*methods)
methods.each { |m| class_eval "def #{m}(*) lock { super } end", __FILE__, __LINE__ }
end
|
Instance Method Details
#add_modules(modules) ⇒ Object
Add a set of modules to the watch stack, remembering the initial constants
98
99
100
101
102
103
104
105
106
107
|
# File 'lib/active_support/dependencies.rb', line 98
def add_modules(modules)
list = modules.map do |desc|
name = Dependencies.to_constant_name(desc)
consts = Dependencies.qualified_const_defined?(name) ?
Inflector.constantize(name).local_constant_names : []
[name, consts]
end
concat(list)
list
end
|
75
76
77
|
# File 'lib/active_support/dependencies.rb', line 75
def get(key)
(val = assoc(key)) ? val[1] : []
end
|
109
110
111
|
# File 'lib/active_support/dependencies.rb', line 109
def lock
@mutex.synchronize { yield self }
end
|
#new_constants_for(frames) ⇒ Object
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/active_support/dependencies.rb', line 81
def new_constants_for(frames)
constants = []
frames.each do |mod_name, prior_constants|
mod = Inflector.constantize(mod_name) if Dependencies.qualified_const_defined?(mod_name)
next unless mod.is_a?(Module)
new_constants = mod.local_constant_names - prior_constants
get(mod_name).concat(new_constants)
new_constants.each do |suffix|
constants << ([mod_name, suffix] - ["Object"]).join("::")
end
end
constants
end
|