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.
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:
The config still exists for DSL-assigned procs like
sort
. Aside from providing a friendly DSL, these configurations need to be duped when subclassing.