Sha256: db42f3e3486b639939190cf2881cc2441cb549fcc064267fa36b8c570c5d4781
Contents?: true
Size: 635 Bytes
Versions: 1
Compression:
Stored size: 635 Bytes
Contents
class Tram::Policy # @private class Validator attr_reader :scope, :name, :block, :stop_on_failure def ==(other) other.is_a?(self.class) && name && other.name == name end def check(object) object.__send__ :instance_variable_set, :@__scope__, scope name ? object.__send__(name) : object.instance_exec(&block) end private def initialize(scope, name, block, stop_on_failure: false) @scope = scope @name = name&.to_sym @block = 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.2.3 | lib/tram/policy/validator.rb |