Module: Bridgetown::Utils::RubyExec

Defined in:
lib/bridgetown-core/utils/ruby_exec.rb

Class Method Summary collapse

Class Method Details

.search_data_for_ruby_code(convertible) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/bridgetown-core/utils/ruby_exec.rb', line 6

def self.search_data_for_ruby_code(convertible)
  return if convertible.data.empty?

  # Iterate using `keys` here so inline Ruby script can add new data keys
  # if necessary without an error
  data_keys = convertible.data.keys
  data_keys.each do |k|
    v = convertible.data[k]
    next unless v.is_a?(Proc)

    convertible.data[k] = convertible.instance_exec(&v)
  end
end