Module: NCore::Create::ClassMethods
- Defined in:
- lib/ncore/methods/create.rb
Instance Method Summary collapse
-
#create(attribs = {}) ⇒ Object
always returns a new object; check .errors? or .valid? to see how it went.
- #create!(attribs = {}) ⇒ Object
Instance Method Details
#create(attribs = {}) ⇒ Object
always returns a new object; check .errors? or .valid? to see how it went
15 16 17 18 19 |
# File 'lib/ncore/methods/create.rb', line 15 def create(attribs={}) obj = new obj.send :create, attribs obj end |
#create!(attribs = {}) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/ncore/methods/create.rb', line 6 def create!(attribs={}) obj = create(attribs) if obj.errors? raise module_parent::RecordInvalid, obj end obj end |