Module: Ripple::Validations::ClassMethods
- Defined in:
- lib/ripple/validations.rb,
lib/ripple/validations/associated_validator.rb
Instance Method Summary collapse
-
#create!(attrs = {}, &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!(attrs = {}, &block) ⇒ Object
Instantiates a new document, applies attributes from a block, and saves it Raises Ripple::DocumentInvalid if the record did not save
53 54 55 56 |
# File 'lib/ripple/validations.rb', line 53 def create!(attrs={}, &block) obj = create(attrs, &block) (raise Ripple::DocumentInvalid.new(obj) if obj.new?) || obj end |
#property(key, type, options = {}) ⇒ Object
46 47 48 49 |
# File 'lib/ripple/validations.rb', line 46 def property(key, type, ={}) prop = super validates key, prop. unless prop..blank? end |
#validates_associated(*attr_names) ⇒ Object
29 30 31 |
# File 'lib/ripple/validations/associated_validator.rb', line 29 def validates_associated(*attr_names) validates_with AssociatedValidator, _merge_attributes(attr_names) end |