Class: Scimitar::Engine

Inherits:
Rails::Engine
  • Object
show all
Defined in:
lib/scimitar/engine.rb

Class Method Summary collapse

Class Method Details

.add_custom_resource(resource) ⇒ Object

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


32
33
34
# File 'lib/scimitar/engine.rb', line 32

def self.add_custom_resource(resource)
  custom_resources << resource
end

.custom_resourcesObject

Returns the list of custom resources, if any.



45
46
47
# File 'lib/scimitar/engine.rb', line 45

def self.custom_resources
  @custom_resources ||= []
end

.default_resourcesObject

Returns the default resources added in this gem:

  • Scimitar::Resources::User

  • Scimitar::Resources::Group



54
55
56
# File 'lib/scimitar/engine.rb', line 54

def self.default_resources
  [ Resources::User, Resources::Group ]
end

.reset_custom_resourcesObject

Resets the resource list to default. This is really only intended for use during testing, to avoid one test polluting another.



39
40
41
# File 'lib/scimitar/engine.rb', line 39

def self.reset_custom_resources
  @custom_resources = []
end

.resourcesObject



11
12
13
# File 'lib/scimitar/engine.rb', line 11

def self.resources
  default_resources + custom_resources
end

.schemasObject



58
59
60
# File 'lib/scimitar/engine.rb', line 58

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