Sha256: ba8724d4dcf46072623d4caed6097dbc4345acc37416a8390fac55f84406e767

Contents?: true

Size: 412 Bytes

Versions: 1

Compression:

Stored size: 412 Bytes

Contents

require "ostruct"

module Predicator
  class Context
    attr_reader :bindings

    def initialize
      @bindings = {}
    end

    def bind name, value
      value = OpenStruct.new(value) if value.kind_of? Hash
      bindings[name.to_s] = value
    end

    def value_for input
      return input unless input.kind_of? Predicator::Variable

      input.value_in self
    end
    alias :[] :value_for
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
predicator-0.3.0 lib/predicator/context.rb