Class: RailsDevelopmentBoost::DependenciesPatch::ConstantsHeap
- Inherits:
-
Array
- Object
- Array
- RailsDevelopmentBoost::DependenciesPatch::ConstantsHeap
- Defined in:
- lib/rails_development_boost/dependencies_patch.rb
Constant Summary collapse
- NAMESPACE_SEPARATOR =
'::'
Instance Method Summary collapse
- #add_const?(const_name, force_insert = false) ⇒ Boolean
- #clear_seen ⇒ Object
-
#initialize(*args) ⇒ ConstantsHeap
constructor
A new instance of ConstantsHeap.
- #pop_next_const ⇒ Object
- #seen?(const_name) ⇒ Boolean
Constructor Details
#initialize(*args) ⇒ ConstantsHeap
Returns a new instance of ConstantsHeap.
176 177 178 179 |
# File 'lib/rails_development_boost/dependencies_patch.rb', line 176 def initialize(*args) super @seen = Set.new end |
Instance Method Details
#add_const?(const_name, force_insert = false) ⇒ Boolean
181 182 183 184 185 186 187 188 |
# File 'lib/rails_development_boost/dependencies_patch.rb', line 181 def add_const?(const_name, force_insert = false) if @seen.add?(const_name) || force_insert (self[const_name.count(NAMESPACE_SEPARATOR)] ||= []) << const_name true else false end end |
#clear_seen ⇒ Object
203 204 205 |
# File 'lib/rails_development_boost/dependencies_patch.rb', line 203 def clear_seen @seen.clear end |
#pop_next_const ⇒ Object
190 191 192 193 194 195 196 197 |
# File 'lib/rails_development_boost/dependencies_patch.rb', line 190 def pop_next_const reverse_each do |slot| if const_name = slot.try(:pop) return const_name end end nil end |
#seen?(const_name) ⇒ Boolean
199 200 201 |
# File 'lib/rails_development_boost/dependencies_patch.rb', line 199 def seen?(const_name) @seen.include?(const_name) end |