Skip to content

Instantly share code, notes, and snippets.

@okitan
Created March 3, 2010 08:22
Show Gist options
  • Save okitan/320434 to your computer and use it in GitHub Desktop.
Save okitan/320434 to your computer and use it in GitHub Desktop.
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