Module: NCore::Update::ClassMethods
- Defined in:
- lib/ncore/methods/update.rb
Instance Method Summary collapse
-
#update(id, attribs) ⇒ Object
always returns a new object; check .errors? or .valid? to see how it went.
- #update!(id, attribs) ⇒ Object
Instance Method Details
#update(id, attribs) ⇒ Object
always returns a new object; check .errors? or .valid? to see how it went
15 16 17 18 19 20 21 |
# File 'lib/ncore/methods/update.rb', line 15 def update(id, attribs) raise(parent::RecordNotFound, "Cannot update id=nil") if id.blank? params = parse_request_params(attribs) obj = new({id: id}, params[:credentials]) obj.update params obj end |
#update!(id, attribs) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/ncore/methods/update.rb', line 6 def update!(id, attribs) obj = update(id, attribs) if obj.errors? raise parent::RecordInvalid, obj end obj end |