Sha256: 3eb5e7db2fc599a9f4220bfc664b9686f0372ee64af56a16d4561d6d98eb298f

Contents?: true

Size: 914 Bytes

Versions: 5

Compression:

Stored size: 914 Bytes

Contents

module Timber
  module Contexts
    # The organization context tracks the organization of the currently
    # authenticated user.
    #
    # You will want to add this context at the time you determine
    # the organization a user belongs to, typically in the authentication
    # flow.
    #
    # Example:
    #
    #   organization_context = Timber::Contexts::Organization.new(id: "abc1234", name: "Timber Inc")
    #   Timber::CurrentContext.with(organization_context) do
    #     # Logging will automatically include this context
    #     logger.info("This is a log message")
    #   end
    #
    class Organization < Context
      attr_reader :id, :name

      def initialize(attributes)
        @id = attributes[:id]
        @name = attributes[:name]
      end

      def keyspace
        :organization
      end

      def as_json(_options = {})
        {id: id, name: name}
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
timber-1.0.3 lib/timber/contexts/organization.rb
timberio-1.0.3 lib/timber/contexts/organization.rb
timberio-1.0.2 lib/timber/contexts/organization.rb
timberio-1.0.1 lib/timber/contexts/organization.rb
timberio-1.0.0 lib/timber/contexts/organization.rb