Sha256: 9ca1e51708adde9babfdc30c9035cb5684cf2fece0d571f0af9cec321c0f8ac4

Contents?: true

Size: 1.56 KB

Versions: 40

Compression:

Stored size: 1.56 KB

Contents

module Scimitar
  class Engine < ::Rails::Engine
    isolate_namespace Scimitar

    Mime::Type.register 'application/scim+json', :scim

    ActionDispatch::Request.parameter_parsers[Mime::Type.lookup('application/scim+json').symbol] = lambda do |body|
      JSON.parse(body)
    end

    def self.resources
      default_resources + custom_resources
    end

    # Can be used to add a new resource type which is not provided by the gem.
    # For example:
    #
    #     module Scim
    #       module Resources
    #         class ShinyResource < Scimitar::Resources::Base
    #           set_schema Scim::Schema::Shiny
    #
    #           def self.endpoint
    #             "/Shinies"
    #           end
    #         end
    #       end
    #     end
    #
    #     Scimitar::Engine.add_custom_resource Scim::Resources::ShinyResource
    #
    def self.add_custom_resource(resource)
      custom_resources << resource
    end

    # Resets the resource list to default. This is really only intended for use
    # during testing, to avoid one test polluting another.
    #
    def self.reset_custom_resources
      @custom_resources = []
    end

    # Returns the list of custom resources, if any.
    #
    def self.custom_resources
      @custom_resources ||= []
    end

    # Returns the default resources added in this gem:
    #
    # * Scimitar::Resources::User
    # * Scimitar::Resources::Group
    #
    def self.default_resources
      [ Resources::User, Resources::Group ]
    end

    def self.schemas
      resources.map(&:schemas).flatten.uniq.map(&:new)
    end

  end
end

Version data entries

40 entries across 40 versions & 2 rubygems

Version Path
scimitar-2.7.3 lib/scimitar/engine.rb
powerhome-scimitar-1.0.0 lib/scimitar/engine.rb
scimitar-2.7.2 lib/scimitar/engine.rb
scimitar-1.8.2 lib/scimitar/engine.rb
scimitar-1.8.1 lib/scimitar/engine.rb
scimitar-2.7.1 lib/scimitar/engine.rb
scimitar-1.8.0 lib/scimitar/engine.rb
scimitar-2.7.0 lib/scimitar/engine.rb
scimitar-1.7.1 lib/scimitar/engine.rb
scimitar-2.6.1 lib/scimitar/engine.rb
scimitar-1.7.0 lib/scimitar/engine.rb
scimitar-2.6.0 lib/scimitar/engine.rb
scimitar-1.6.0 lib/scimitar/engine.rb
scimitar-2.5.0 lib/scimitar/engine.rb
scimitar-2.4.3 lib/scimitar/engine.rb
scimitar-1.5.3 lib/scimitar/engine.rb
scimitar-1.5.2 lib/scimitar/engine.rb
scimitar-2.4.2 lib/scimitar/engine.rb
scimitar-2.4.1 lib/scimitar/engine.rb
scimitar-2.4.0 lib/scimitar/engine.rb