Class: CodebrekerManfly::ValidatableEntity

Inherits:
Object
  • Object
show all
Includes:
Validator
Defined in:
lib/codebreker_manfly/entities/validatable_entity.rb

Direct Known Subclasses

CodeGenerator, CodeMatcher, Difficulty, Game, Guess, User

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Validator

#valid_class?, #valid_non_empty_string?, #valid_non_negative_integer?, #valid_only_numeric_string?, #valid_positive_integer?, #valid_range?, #valid_string_max_length?, #valid_string_min_length?

Constructor Details

#initializeValidatableEntity

Returns a new instance of ValidatableEntity.



9
10
11
# File 'lib/codebreker_manfly/entities/validatable_entity.rb', line 9

def initialize
  @errors = {}
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



7
8
9
# File 'lib/codebreker_manfly/entities/validatable_entity.rb', line 7

def errors
  @errors
end

Instance Method Details

#valid?Boolean

Returns:

  • (Boolean)


13
14
15
16
# File 'lib/codebreker_manfly/entities/validatable_entity.rb', line 13

def valid?
  validate
  errors.empty?
end