Sha256: 14c446bf45eede717beafe9e092dd0d8a2f043a49a04fe6c83638fa02d9c50a5

Contents?: true

Size: 920 Bytes

Versions: 15

Compression:

Stored size: 920 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")
    #   logger.with_context(organization_context) do
    #     # Logging will automatically include this context
    #     logger.info("This is a log message")
    #   end
    #
    class Organization < Context
      @keyspace = :organization

      attr_reader :id, :name

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

      def as_json(_options = {})
        {id: Timber::Util::Object.try(id, :to_s), name: name}
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
timber-2.0.24 lib/timber/contexts/organization.rb
timber-2.0.23 lib/timber/contexts/organization.rb
timber-2.0.22 lib/timber/contexts/organization.rb
timber-2.0.21 lib/timber/contexts/organization.rb
timber-2.0.20 lib/timber/contexts/organization.rb
timber-2.0.19 lib/timber/contexts/organization.rb
timber-2.0.17 lib/timber/contexts/organization.rb
timber-2.0.16 lib/timber/contexts/organization.rb
timber-2.0.15 lib/timber/contexts/organization.rb
timber-2.0.14 lib/timber/contexts/organization.rb
timber-2.0.12 lib/timber/contexts/organization.rb
timber-2.0.11 lib/timber/contexts/organization.rb
timber-2.0.10 lib/timber/contexts/organization.rb
timber-2.0.9 lib/timber/contexts/organization.rb
timber-2.0.8 lib/timber/contexts/organization.rb