Module: Insta::Inline::PendingRegistry

Defined in:
lib/insta/inline/pending_registry.rb,
sig/insta/inline/pending_registry.rbs

Class Method Summary collapse

Class Method Details

.add(file:, line:, content:, type:) ⇒ void

This method returns an undefined value.

: (file: String, line: Integer, content: String, type: Symbol) -> void

Parameters:

  • file: (String)
  • line: (Integer)
  • content: (String)
  • type: (Symbol)


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

Returns:

  • (Boolean)


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

.sizeInteger

: () -> Integer

Returns:

  • (Integer)


47
48
49
# File 'lib/insta/inline/pending_registry.rb', line 47

def self.size
  @mutex.synchronize { @pending.values.sum(&:length) }
end