Sha256: 2651206ea9035a7f389aabad57923b8886cda41a5e2ca0f603a2c9117c112058

Contents?: true

Size: 1.27 KB

Versions: 1

Compression:

Stored size: 1.27 KB

Contents

module JSONAPIonify::Api
  module Resource::Defaults::Options
    extend ActiveSupport::Concern
    included do
      id :id
      scope { raise NotImplementedError, 'scope not implemented' }
      collection { raise NotImplementedError, 'collection not implemented' }
      instance { raise NotImplementedError, 'instance not implemented' }
      new_instance { raise NotImplementedError, 'new instance not implemented' }

      context :scope_defined? do |context|
        begin
          !!context.scope
        rescue NotImplementedError
          false
        end
      end

      context :collection_defined? do |context|
        begin
          !!context.collection
        rescue NotImplementedError
          false
        end
      end

      context :instance_defined? do |context|
        begin
          !!context.instance
        rescue NotImplementedError
          false
        end
      end

      context :new_instance_defined? do |context|
        begin
          !!context.new_instance
        rescue NotImplementedError
          false
        end
      end

      before do |context|
        context.request_headers # pull request_headers so they verify
      end

      before do |context|
        context.params # pull params so they verify
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jsonapionify-0.9.0 lib/jsonapionify/api/resource/defaults/options.rb