Class: String

Inherits:
Object
  • Object
show all
Includes:
Funcml
Defined in:
lib/funcml-core/patch/string.rb

Constant Summary

Constants included from Funcml

Funcml::VERSION

Instance Method Summary collapse

Instance Method Details

#dig(_) ⇒ Object



22
23
24
# File 'lib/funcml-core/patch/string.rb', line 22

def dig(_)
  self
end

#mutate(mutations) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/funcml-core/patch/string.rb', line 7

def mutate(mutations)
  if self.start_with?('$')

    return Time.now.to_s if self.eql?('$now')
    return SecureRandom.uuid if self.eql?('$uuidv4')

    mutations.dig_from_str(self.gsub('$', ''), mutations).then do |value|
      raise MutationException, "`#{self}` not found in mutations, available mutations: #{mutations.to_s}" if value.nil?
      return value.mutate(mutations)
    end
  end

  self
end