123456789_123456789_123456789_123456789_123456789_

Class: Test::Unit::AttributeMatcher

Relationships & Source Files
Inherits: Object
Defined in: lib/test/unit/attribute-matcher.rb

Class Method Summary

Instance Method Summary

Constructor Details

.new(test) ⇒ AttributeMatcher

[ GitHub ]

  
# File 'lib/test/unit/attribute-matcher.rb', line 4

def initialize(test)
  @test = test
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args)

[ GitHub ]

  
# File 'lib/test/unit/attribute-matcher.rb', line 17

def method_missing(name, *args)
  if args.empty?
    @test[name]
  else
    super
  end
end

Instance Method Details

#match?(expression) ⇒ Boolean

[ GitHub ]

  
# File 'lib/test/unit/attribute-matcher.rb', line 8

def match?(expression)
  matched = instance_eval(expression)
  if matched.nil?
    false
  else
    matched
  end
end