Comments (5)
If an errors collection is empty, it acquires the status code from the first item added.
I'm not sure you should be mutating the errors instance inline, but if you are, it'd be a question of removing the one error entry (which might empty the collection) then adding a new one (which if the collection was now empty should auto-set the status code for you).
from hoodoo.
The reason we are mutating here is because the errors instance could already have more than one error in it. So removing it then adding a new one might not be adding it to an empty array, which then wouldn't update the status code.
from hoodoo.
Now that I think about it one possible way to do it now is to dup the errors, modiy them, empty the Hoodoo:Errors#errors collection, then add all the new modified errors in.
from hoodoo.
I'd probably:
- Create a new Errors instance
- Iterate through the source Errors instance, transmogrifying entires if necessary
- Call
add_precompiled_error
on the new Errors instance to add the possibly-altered error entries back
Done. Actually it's probably even cleaner to iterate, then either add_precompiled_error
for one you aren't modifying, or use add_error
to add the thing or things you actually want for the case when you want to change an entry into something else. Code should be easier to read.
See also the source code for Errors#merge!
in errors.rb
.
from hoodoo.
I'm going to close this, I implemented this with public APIs here: https://github.com/LoyaltyNZ/service_purchase/pull/108
from hoodoo.
Related Issues (20)
- Deep nested Hash defaults in presenter default cannot render
- Resource name/route aliases
- DEFAULT_TEST_SESSION injected into public actions when in test and development environments
- Review HTTP(S) proxy situation for Client
- Response#set_resources and #set_estimated_resources do not check type
- Service implementation dispatch #before / #after are not documented HOT 1
- Hoodoo::TransientStore Regression in Mock response for Test environments. HOT 2
- Consider fundamental alteration of action method structure HOT 1
- X-Deja-Vu response should be more helpful HOT 1
- HTTP host/port discovery via Rack monkey patch isn't patching (in Rack 2, possibly earlier)?
- Introduce '!' method equivalents given new 'acquire_in'/'acquire_in!'
- Consider removing WebMock dependency
- Allow a schema to be aliased HOT 1
- Alias #resource as #endpoint HOT 1
- X-Dated-At header allow some wriggle room HOT 2
- Refine test sessions to only have permissions for declared interfaces
- Scaffold generator in service shell
- Survive missing columns for default framework search fields
- Automated validation of search/filter fields
- Round up estimated-dataset-size
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hoodoo.