Class: SettingsReader::Resolvers::Erb

Inherits:
Abstract
  • Object
show all
Defined in:
lib/settings_reader/resolvers/erb.rb

Overview

Run values through ERB

Constant Summary collapse

IDENTIFIER =
/(<%=).*(%>)/.freeze

Constants included from Mixins::Values

Mixins::Values::PARSING_CLASSES

Instance Method Summary collapse

Methods included from Mixins::Values

#cast_value_from_string, #get_value_from_hash

Instance Method Details

#resolvable?(value, _path) ⇒ Boolean

Returns true when value contain Erb template <%= code_is_here %>

Returns:

  • (Boolean)


8
9
10
11
12
# File 'lib/settings_reader/resolvers/erb.rb', line 8

def resolvable?(value, _path)
  return unless value.is_a?(String)

  IDENTIFIER.match?(value)
end

#resolve(value, _path) ⇒ Object

Renders value using ERB



15
16
17
# File 'lib/settings_reader/resolvers/erb.rb', line 15

def resolve(value, _path)
  ERB.new(value.to_s).result
end