Sha256: 57c789dc12657f43cf065d3770a1709ff87df56446c05d69434e968f79e087c8

Contents?: true

Size: 593 Bytes

Versions: 2

Compression:

Stored size: 593 Bytes

Contents

module ActsAsTenant
  class Configuration
    attr_writer :require_tenant, :pkey

    def require_tenant
      @require_tenant ||= false
    end

    def pkey
      @pkey ||= :id
    end

    def job_scope
      @job_scope || ->(relation) { relation.all }
    end

    # Used for looking job tenants in background jobs
    #
    # Format matches Rails scopes
    #
    #   job_scope = ->(relation) {}
    #   job_scope = -> {}
    def job_scope=(scope)
      @job_scope = if scope && scope.arity == 0
        proc { instance_exec(&scope) }
      else
        scope
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
acts_as_tenant-1.0.1 lib/acts_as_tenant/configuration.rb
acts_as_tenant-1.0.0 lib/acts_as_tenant/configuration.rb