Class: Lesli::ApplicationLesliValidator

Inherits:
Object
  • Object
show all
Defined in:
app/validators/lesli/application_lesli_validator.rb

Direct Known Subclasses

UsersValidator

Instance Method Summary collapse

Constructor Details

#initialize(resource) ⇒ ApplicationLesliValidator

Returns a new instance of ApplicationLesliValidator.



40
41
42
43
44
45
46
47
48
# File 'app/validators/lesli/application_lesli_validator.rb', line 40

def initialize(resource)

    # stores the resources from the database as result of the active record queries
    @resource = resource

    # stores any error found during the life-cycle of the service object
    @failures = []

end

Instance Method Details

#valid? {|failures.empty?, failures| ... } ⇒ Boolean

Yields:

  • (failures.empty?, failures)

Returns:

  • (Boolean)


50
51
52
53
# File 'app/validators/lesli/application_lesli_validator.rb', line 50

def valid?
    yield(failures.empty?, failures) if block_given?
    failures.empty?
end