Sha256: b48340c27f63b6ac98d256d676eed6c64728899373638e685ef86b05e7c5c128

Contents?: true

Size: 928 Bytes

Versions: 19

Compression:

Stored size: 928 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
      @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

19 entries across 19 versions & 1 rubygems

Version Path
timber-2.0.7 lib/timber/contexts/organization.rb
timber-2.0.6 lib/timber/contexts/organization.rb
timber-2.0.5 lib/timber/contexts/organization.rb
timber-2.0.4 lib/timber/contexts/organization.rb
timber-2.0.3 lib/timber/contexts/organization.rb
timber-2.0.2 lib/timber/contexts/organization.rb
timber-2.0.1 lib/timber/contexts/organization.rb
timber-2.0.0 lib/timber/contexts/organization.rb
timber-1.1.14 lib/timber/contexts/organization.rb
timber-1.1.13 lib/timber/contexts/organization.rb
timber-1.1.12 lib/timber/contexts/organization.rb
timber-1.1.11 lib/timber/contexts/organization.rb
timber-1.1.10 lib/timber/contexts/organization.rb
timber-1.1.9 lib/timber/contexts/organization.rb
timber-1.1.8 lib/timber/contexts/organization.rb
timber-1.1.7 lib/timber/contexts/organization.rb
timber-1.1.6 lib/timber/contexts/organization.rb
timber-1.1.5 lib/timber/contexts/organization.rb
timber-1.1.4 lib/timber/contexts/organization.rb