Sha256: 8404b6af1ecec5eaafd6562d446e2e723d9d65cc5c6d66e712fd9c72eaa36ba2
Contents?: true
Size: 552 Bytes
Versions: 1
Compression:
Stored size: 552 Bytes
Contents
class Tram::Policy # @private class Validator attr_reader :name, :block, :stop_on_failure def ==(other) other.is_a?(self.class) && name && other.name == name end def check(object) name ? object.__send__(name) : object.instance_exec(&block) end private def initialize(name, block, stop_on_failure: false) @name = name&.to_sym @block = lambda(&block) if block raise "Provide either method name or a block" unless !name ^ !block @stop_on_failure = stop_on_failure end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tram-policy-0.3.0 | lib/tram/policy/validator.rb |