lib/jsonapionify/api/resource/definitions/helpers.rb in jsonapionify-0.0.1.pre vs lib/jsonapionify/api/resource/definitions/helpers.rb in jsonapionify-0.9.0

- old
+ new

@@ -3,7 +3,25 @@ def helper(name, &block) define_method(name, &block) end + def authentication(&block) + context :authentication, readonly: true do |context| + OpenStruct.new.tap do |authentication_object| + if instance_exec(context.request, authentication_object, &block) == false + error_now :forbidden + end + end + end + + before do |context| + context.authentication + end + end + + def on_exception(&block) + before_exception &block + end + end end