Sha256: 3bf28cc8fc81e340245cadf72e4e75799c7b6143015cda10f3de96f3b9f9145e

Contents?: true

Size: 1.25 KB

Versions: 16

Compression:

Stored size: 1.25 KB

Contents

#
# This class provides an abstract for the tenant interface. Whilst any Proc
# could be used, it's safest for people to sub-class to ensure that any future
# interface changes are catered for.
#
# A tenant class's responsibility is to receive a block, around which it should
# handle switching to the given tenant's configuration, ensuring that if an
# exception occurs, the configuration is reset back to the global configuration.
#
module Penthouse
  module Tenants
    class BaseTenant
      attr_accessor :identifier
      private :identifier=

      # @param identifier [String, Symbol] An identifier for the tenant
      def initialize(identifier)
        self.identifier = identifier
      end

      # @abstract placeholder for the relevant tenant-switching code
      # @param block [Block] The code to execute within the tenant
      # @yield [BaseTenant] The current tenant instance
      # @return [void]
      def call(&block)
        raise NotImplementedError
      end

      # @abstract creates the tenant data store
      # @return [void]
      def create(*)
        raise NotImplementedError
      end

      # @abstract deletes the tenant data store
      # @return [void]
      def delete(*)
        raise NotImplementedError
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
penthouse-0.11.0 lib/penthouse/tenants/base_tenant.rb
penthouse-0.10.1 lib/penthouse/tenants/base_tenant.rb
penthouse-0.10.0 lib/penthouse/tenants/base_tenant.rb
penthouse-0.9.0 lib/penthouse/tenants/base_tenant.rb
penthouse-0.8.0 lib/penthouse/tenants/base_tenant.rb
penthouse-0.7.5 lib/penthouse/tenants/base_tenant.rb
penthouse-0.7.4 lib/penthouse/tenants/base_tenant.rb
penthouse-0.7.3 lib/penthouse/tenants/base_tenant.rb
penthouse-0.7.2 lib/penthouse/tenants/base_tenant.rb
penthouse-0.7.1 lib/penthouse/tenants/base_tenant.rb
penthouse-0.7.0 lib/penthouse/tenants/base_tenant.rb
penthouse-0.6.0 lib/penthouse/tenants/base_tenant.rb
penthouse-0.5.0 lib/penthouse/tenants/base_tenant.rb
penthouse-0.4.2 lib/penthouse/tenants/base_tenant.rb
penthouse-0.4.1 lib/penthouse/tenants/base_tenant.rb
penthouse-0.4.0 lib/penthouse/tenants/base_tenant.rb