class Fluidity::Grammer::Base
Public Class Methods
new(target, negate=false)
click to toggle source
# File lib/fluidity/grammer.rb, line 9 def initialize(target, negate=false) @target = target @negate = negate end
Public Instance Methods
==(other)
click to toggle source
Have to override the ususal ‘#==` method to support this.
# File lib/fluidity/grammer.rb, line 15 def ==(other) if @negate ::EqualAssay.refute!(@target, other, :backtrace=>caller) else ::EqualAssay.assert!(@target, other, :backtrace=>caller) end end
method_missing(s, *a, &b)
click to toggle source
private
Calls superclass method
# File lib/fluidity/grammer.rb, line 25 def method_missing(s, *a, &b) if assay = (::Assertion.by_name(s) || ::Assertion.by_operator(s)) if @negate assay.refute!(@target, *a, &b) else assay.assert!(@target, *a, &b) end else q = (s.to_s.end_with?('?') ? s : (s.to_s+'?')) if @target.respond_to?(q) assert(false, "#{q} failed", caller) unless @target.send(q, *a, &b) else super(s, *a, &b) end end end