Module: Insta::Inline::PendingRegistry
- Defined in:
- lib/insta/inline/pending_registry.rb,
sig/insta/inline/pending_registry.rbs
Class Method Summary collapse
-
.add(file:, line:, content:, type:) ⇒ void
: (file: String, line: Integer, content: String, type: Symbol) -> void.
-
.any? ⇒ Boolean
: () -> bool.
-
.clear! ⇒ void
: () -> void.
-
.flush! ⇒ void
: () -> void.
-
.size ⇒ Integer
: () -> Integer.
Class Method Details
.add(file:, line:, content:, type:) ⇒ void
This method returns an undefined value.
: (file: String, line: Integer, content: String, type: Symbol) -> void
10 11 12 13 14 15 |
# File 'lib/insta/inline/pending_registry.rb', line 10 def self.add(file:, line:, content:, type:) @mutex.synchronize do @pending[file] = @pending[file] || [] #: Array[Inline::pending_entry] @pending[file] << { line: line, content: content, type: type } end end |
.any? ⇒ Boolean
: () -> bool
42 43 44 |
# File 'lib/insta/inline/pending_registry.rb', line 42 def self.any? @mutex.synchronize { !@pending.empty? } end |
.clear! ⇒ void
This method returns an undefined value.
: () -> void
52 53 54 |
# File 'lib/insta/inline/pending_registry.rb', line 52 def self.clear! @mutex.synchronize { @pending.clear } end |
.flush! ⇒ void
This method returns an undefined value.
: () -> void
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/insta/inline/pending_registry.rb', line 18 def self.flush! entries = @mutex.synchronize do result = @pending.dup @pending.clear result end return if entries.empty? entries.each do |file, pending_entries| unless File.exist?(file) warn "insta: skipping inline snapshot update for missing file: #{file}" next end patched = FilePatcher.patch(file, pending_entries) FilePatcher.atomic_write(file, patched) end end |
.size ⇒ Integer
: () -> Integer
47 48 49 |
# File 'lib/insta/inline/pending_registry.rb', line 47 def self.size @mutex.synchronize { @pending.values.sum(&:length) } end |