class Exclaim::Bind

Attributes

json_declaration[R]
path[R]

Public Class Methods

new(path:, json_declaration: nil) click to toggle source
# File lib/exclaim/bind.rb, line 7
def initialize(path:, json_declaration: nil)
  raise UiConfigurationError.new("$bind path must be a String, found #{path.class}") unless path.is_a?(String)

  @json_declaration = json_declaration
  self.path = path
end

Public Instance Methods

evaluate(env) click to toggle source
# File lib/exclaim/bind.rb, line 24
def evaluate(env)
  env.dig(*@path_keys_for_arrays) || env.dig(*@path_keys)
end
path=(value) click to toggle source
# File lib/exclaim/bind.rb, line 14
def path=(value)
  @path = value
  @path_keys = @path.split('.')
  @path_keys_for_arrays = @path_keys.map do |string|
    Integer(string)
  rescue ArgumentError, TypeError
    string
  end
end