Sha256: 388a87aad686d19a01ce7ff9be1e1edac590c9099f1d1382516a78f7d8b25fe2

Contents?: true

Size: 414 Bytes

Versions: 8

Compression:

Stored size: 414 Bytes

Contents

module Erlectricity
  class Matcher
    attr_accessor :condition, :block
    attr_accessor :receiver

    def initialize(parent, condition, block)
      self.receiver = parent
      @block = block
      @condition = Condition.for(condition)
    end

    def run(arg)
      args = @condition.binding_for(arg)
      block.call(*args)
    end

    def matches?(arg)
      @condition.satisfies?(arg)
    end
  end
end

Version data entries

8 entries across 8 versions & 3 rubygems

Version Path
mojombo-erlectricity-1.0.0 lib/erlectricity/matcher.rb
mojombo-erlectricity-1.0.1 lib/erlectricity/matcher.rb
mojombo-erlectricity-1.0.2 lib/erlectricity/matcher.rb
erlectricity-funbox-1.1.2 lib/erlectricity/matcher.rb
erlectricity-1.1.1 lib/erlectricity/matcher.rb
erlectricity-1.1.0 lib/erlectricity/matcher.rb
erlectricity-1.0.1 lib/erlectricity/matcher.rb
erlectricity-1.0.0 lib/erlectricity/matcher.rb