aptible / aptible-resource Goto Github PK
View Code? Open in Web Editor NEWFoundation classes for Aptible resource server gems
License: MIT License
Foundation classes for Aptible resource server gems
License: MIT License
So far it's:
$ grep -r hyperresource-aptible */Gemfile.lock | sed 's/:.*//' | sort | uniq
api.aptible.com/Gemfile.lock
aptible-cli/Gemfile.lock
megatron/Gemfile.lock
policy.aptible.com/Gemfile.lock
primetime/Gemfile.lock
For example, Aptible::Auth::User.new.roles
should be []
, not nil
.
See also #11.
@database.errors
# => #<Aptible::Resource::Errors:0x007fe94d746330 @messages={:base=>"Validation failed: Handle can't be blank, Handle is invalid"}, @full_messages=["Validation failed: Handle can't be blank, Handle is invalid"], @status_code=422>
@database.class
# => Aptible::Resource::Base
@database
# >> (pry) output error: #<RuntimeError: Resource server namespace must be defined by subclass>
We cache links in the accessors we create for relations, but we don't check that they're still valid before returning them.
If you run something.update(a_relation: new_object, some_other_field: new_value)
, then something.some_other_field
will return the new value, but something.a_relation
will continue to return the old value (even though the new link was included in the response).
A workaround is to run: something = something.reload
after the update.
As an alternative for requiring explicit embeds_*
/ has_*
definition.
The current #create_XXX
methods (e.g. app.create_operation
) swallow errors, and return a Aptible::Resource::Base
object, which can be very confusing, especially considering that attempting to reload those resources will throw an immensely cryptic Resource server root URL must be defined by subclass
error.
Now, we do have equivalent bang methods (e.g. app.create_operation!
), which do throw exception, but they're not used everywhere.
For example, in aptible-integration
, we're using app.create_operation
practically everywhere), and when it started throwing Resource server root URL must be defined by subclass
(https://travis-ci.com/aptible/aptible-integration/jobs/41749266), it wasn't immediately obvious at all that the cause was in API (ultimately https://github.com/aptible/api.aptible.com/pull/373).
Is there value in having methods that swallow errors? Is there value in that being the most natural method call? I think the answer to both questions is no, and I think we should simply make both methods do the same thing (i.e. raise exceptions), and possibly raise a deprecation warning on the bang methods that they're now redundant.
Thoughts @blakepettersson @fancyremarker?
It should be possible to instantiate a new resource with parameters, for referencing purposes.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.