Module: Ripple::Validations::ClassMethods
- Defined in:
- lib/ripple/validations.rb,
lib/ripple/validations/associated_validator.rb
Instance Method Summary collapse
-
#create!(*args, &block) ⇒ Object
Instantiates a new document, applies attributes from a block, and saves it Raises Ripple::DocumentInvalid if the record did not save.
- #property(key, type, options = {}) ⇒ Object
- #validates_associated(*attr_names) ⇒ Object
Instance Method Details
#create!(*args, &block) ⇒ Object
Instantiates a new document, applies attributes from a block, and saves it Raises Ripple::DocumentInvalid if the record did not save
39 40 41 42 |
# File 'lib/ripple/validations.rb', line 39 def create!(*args, &block) obj = create(*args, &block) (raise Ripple::DocumentInvalid.new(obj) if obj.new?) || obj end |
#property(key, type, options = {}) ⇒ Object
32 33 34 35 |
# File 'lib/ripple/validations.rb', line 32 def property(key, type, ={}) prop = super validates key, prop. unless prop..blank? end |
#validates_associated(*attr_names) ⇒ Object
38 39 40 |
# File 'lib/ripple/validations/associated_validator.rb', line 38 def validates_associated(*attr_names) validates_with AssociatedValidator, _merge_attributes(attr_names) end |