Class: Rule::Base

Inherits:
Object
  • Object
show all
Includes:
Assertions
Defined in:
lib/rule/base.rb

Direct Known Subclasses

Allow, Disallow

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Assertions

#assert, #assert_absence_of, #assert_presence_of

Constructor Details

#initialize(object) ⇒ Base

Returns a new instance of Base.



5
6
7
8
# File 'lib/rule/base.rb', line 5

def initialize(object)
  @object = object
  @errors = []
end

Instance Attribute Details

#objectObject (readonly)

Returns the value of attribute object.



4
5
6
# File 'lib/rule/base.rb', line 4

def object
  @object
end

Instance Method Details

#add_error(error) ⇒ Object



10
11
12
# File 'lib/rule/base.rb', line 10

def add_error(error)
  @errors << error
end

#pass?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/rule/base.rb', line 14

def pass?
  validate != false and @errors.none?
end