Sha256: fc23a9eacae812e6d44e68e1141ed8977bfb600f662b2b8aabf36fe38dfe0a0b

Contents?: true

Size: 590 Bytes

Versions: 1

Compression:

Stored size: 590 Bytes

Contents

module JSONAPIonify::Api
  module Resource::Definitions::Helpers

    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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jsonapionify-0.9.0 lib/jsonapionify/api/resource/definitions/helpers.rb