Class: Kongo::Model
- Inherits:
-
Object
- Object
- Kongo::Model
- Defined in:
- lib/validate/kongo.rb
Class Method Summary collapse
-
.add_validation_extension(collection_name, mod) ⇒ Object
This is the same as add_extension, but should be used to add validation extensions, which are implemented differently from regular extensions.
Instance Method Summary collapse
- #failures ⇒ Object
-
#initialize(*args) ⇒ Model
constructor
A new instance of Model.
-
#original_initialize ⇒ Object
Override initialize to also set @validator.
-
#validates? ⇒ Boolean
Implements interface to validations via the two usual methods.
Constructor Details
#initialize(*args) ⇒ Model
Returns a new instance of Model.
43 44 45 46 47 |
# File 'lib/validate/kongo.rb', line 43 def initialize(*args) ret = original_initialize(*args) @validator = (@@validations ||= {})[@coll.name.to_sym] ret end |
Class Method Details
.add_validation_extension(collection_name, mod) ⇒ Object
This is the same as add_extension, but should be used to add validation extensions, which are implemented differently from regular extensions.
36 37 38 |
# File 'lib/validate/kongo.rb', line 36 def self.add_validation_extension(collection_name, mod) (@@validations ||= {})[collection_name.to_sym] = mod.validations end |
Instance Method Details
#failures ⇒ Object
54 55 56 |
# File 'lib/validate/kongo.rb', line 54 def failures @validator.failures end |
#original_initialize ⇒ Object
Override initialize to also set @validator.
42 |
# File 'lib/validate/kongo.rb', line 42 alias :original_initialize :initialize |
#validates? ⇒ Boolean
Implements interface to validations via the two usual methods.
51 52 53 |
# File 'lib/validate/kongo.rb', line 51 def validates? @validator.validates?(self) end |