Sha256: b64bc38076587cc6bd8898017b28a2bd245f7fe15b1a03554dad5c09dec399be

Contents?: true

Size: 543 Bytes

Versions: 1

Compression:

Stored size: 543 Bytes

Contents

module Predicator
  class Variable
    attr_reader :model, :attribute

    def initialize model, attribute
      @model = model
      @attribute = attribute
    end

    def value_in context
      entity_name = model.to_s
      entity = context.bindings[model]
      if entity.nil?
        raise ArgumentError, "Unknown entity #{entity_name}"
      else
        entity.send attribute
      end
    end

    def == other
      other.kind_of?(self.class) &&
        other.model == model &&
        other.attribute == attribute
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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