jsonapi-suite / jsonapi_compliable

MIT License
20 stars 35 forks source link

1.0 attributes #111

Closed richmolj closed 6 years ago

richmolj commented 6 years ago

The intent here is to A) break apart the resource class Configuration and DSL-specific code from the overrideable API B) avoid DSL whenever possible in favor of class_attribute.

This follows what you'd see in ActiveRecord:

 # instead of this
class PostResource < ApplicationResource
  model Post
  type :posts
  use_adapter FooAdapter
end
PostResource.config[:model]
PostResource.config[:type]
PostResource.config[:adapter]

 # we now have this
class PostResource < ApplicationResource
  self.model = Post
  self.type = :posts
  self.adapter = FooAdapter.new
end
PostResource.model
PostResource.type
PostResource.adapter

The config still exists for DSL-assigned procs like sort. Aside from providing a friendly DSL, these configurations need to be duped when subclassing.

richmolj commented 6 years ago

@wadetandy on top of https://github.com/jsonapi-suite/jsonapi_compliable/pull/110

richmolj commented 6 years ago

Now in 1.0.0-dev branch