class Assertion::Inverter
Builds inversions for instances of some ‘Assertion::Base` subclass
@example
IsAdult = Assertion.about :name, :age do age >= 18 end joe = OpenStruct.new(name: "Joe", age: 40) child = Inverter.new(IsAdult) child[name: "Joe"].validate! # => #<Assertion::InvalidError @messages=["Joe is an adult (age 40)"]>
Attributes
source[R]
@!attribute [r] source
@return [Class] The ‘Assertion::Base` sublcass to build negators for
Public Class Methods
new(source)
click to toggle source
@private
# File lib/assertion/inverter.rb, line 37 def initialize(source) @source = source IceNine.deep_freeze(self) end
Public Instance Methods
new(hash = {})
click to toggle source
Initializes a [#source] object and builds a negator for it
@param [Hash] hash The hash of attributes to apply the assertion to
@return [Assertion::Inverter::Inversion]
# File lib/assertion/inverter.rb, line 48 def new(hash = {}) Inversion.new source.new(hash) end