Created
March 3, 2010 08:22
-
-
Save okitan/320434 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module RR::Adapters::RRMethods | |
def lazy(expected) | |
RR::WildcardMatchers::LazyMatcher.new(expected) | |
end | |
end | |
module RR::WildcardMatchers | |
class LazyMatcher | |
def initialize(value) | |
@value = value | |
end | |
def ==(other) | |
if @value.is_a?(Hash) | |
@value.keys.each {|key| @value[key] = @value[key].call if @value[key].is_a?(Proc) } | |
elsif @value.is_a?(Array) | |
@value.map! {|v| v.is_a?(Proc) ? v.call : v } | |
elsif @value.is_a?(Proc) | |
@value = @value.call | |
end | |
@value == other | |
end | |
def inspect | |
@value.inspect | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment