Curies, embeds, zoom and more #14

Merged
merged 18 commits into from Mar 5, 2014

Projects

None yet

3 participants

@kookster
Member
kookster commented Mar 5, 2014

big commit, getting various functionality playing nice together:

  • define curies in base representer
  • define self in base representer
  • add profiles to all self links
  • add embed and embeds methods to representer related resources, control default zoom
  • add to models and base controller to tag instances if they are the root resource, (and get curies and embeds)
  • add in support for zoom (or z) request param to show more embeds in root resource

some smaller fixes:

  • new relic added for basic request analysis
  • return 404 for AR not found errors
  • rename PRXModel to BaseModel to be more consistent
  • make PagedCollection have smarter defaults, not need a http request obj to construct
  • use title attr in links rather than sometimes name and sometimes title
@chrisrhoden chrisrhoden and 1 other commented on an outdated diff Mar 5, 2014
app/controllers/api/base_controller.rb
@@ -1,6 +1,12 @@
class Api::BaseController < ApplicationController
protect_from_forgery with: :null_session
+ rescue_from ActiveRecord::RecordNotFound, with: :record_not_found
@chrisrhoden
chrisrhoden Mar 5, 2014 Public Radio Exchange member

Is this not the default behavior in production? or is this just so that the error message is in json?

@kookster
kookster Mar 5, 2014 Public Radio Exchange member

no, you are right, the error with cors middleware was masking this when I tested prod settings, fixed that too now.

@coveralls

Coverage Status

Coverage remained the same when pulling e17a85e on kookster:curies into 903e5d5 on PRX:master.

@coveralls

Coverage Status

Coverage remained the same when pulling e17a85e on kookster:curies into 903e5d5 on PRX:master.

@chrisrhoden chrisrhoden commented on the diff Mar 5, 2014
app/representers/api/base_representer.rb
@@ -0,0 +1,27 @@
+# encoding: utf-8
+
+class Api::BaseRepresenter < Roar::Decorator
+
+ include Roar::Representer::JSON::HAL
+ include UriMethods
+ include Curies
+ include Embeds
+
+ curies(:prx) do
@chrisrhoden
chrisrhoden Mar 5, 2014 Public Radio Exchange member

Making sure I understand, the parameter to curies sets the default curie going forward, correct? and the block actually defines the curie? Making sure that the two :prxs aren't redundant (they don't seem to be)

@kookster
kookster Mar 5, 2014 Public Radio Exchange member

correct, you can have multiple curie links, the one as the arg to curies(arg) is selected as the default.

@kookster
Member
kookster commented Mar 5, 2014

broke build with change for 404 handling, whoops.

@chrisrhoden chrisrhoden merged commit e010193 into PRX:master Mar 5, 2014

1 check passed

Details default The Travis CI build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment