Class: Tram::Policy::Validator

Inherits:
Object
  • Object
show all
Defined in:
lib/tram/policy/validator.rb

Overview

Describes a validator

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



4
5
6
# File 'lib/tram/policy/validator.rb', line 4

def block
  @block
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/tram/policy/validator.rb', line 4

def name
  @name
end

#scopeObject (readonly)

Returns the value of attribute scope.



4
5
6
# File 'lib/tram/policy/validator.rb', line 4

def scope
  @scope
end

#stop_on_failureObject (readonly)

Returns the value of attribute stop_on_failure.



4
5
6
# File 'lib/tram/policy/validator.rb', line 4

def stop_on_failure
  @stop_on_failure
end

Instance Method Details

#==(other) ⇒ Object



6
7
8
# File 'lib/tram/policy/validator.rb', line 6

def ==(other)
  other.is_a?(self.class) && name && other.name == name
end

#check(object) ⇒ Object



10
11
12
13
14
15
# File 'lib/tram/policy/validator.rb', line 10

def check(object)
  object.__send__ :instance_variable_set, :@__scope__, scope
  name ? object.__send__(name) : object.instance_exec(&block)
rescue
  object.__send__ :instance_variable_set, :@__scope__, nil
end