Sha256: f69c2402f348de8c95efdb0f197f70b5b79accfd5793d18f7b9e14b3b87fbe22

Contents?: true

Size: 895 Bytes

Versions: 13

Compression:

Stored size: 895 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: id, name: name}
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
timber-1.1.2 lib/timber/contexts/organization.rb
timber-1.1.1 lib/timber/contexts/organization.rb
timber-1.1.0 lib/timber/contexts/organization.rb
timber-1.0.13 lib/timber/contexts/organization.rb
timber-1.0.12 lib/timber/contexts/organization.rb
timber-1.0.11 lib/timber/contexts/organization.rb
timber-1.0.10 lib/timber/contexts/organization.rb
timber-1.0.9 lib/timber/contexts/organization.rb
timber-1.0.8 lib/timber/contexts/organization.rb
timber-1.0.7 lib/timber/contexts/organization.rb
timber-1.0.6 lib/timber/contexts/organization.rb
timber-1.0.5 lib/timber/contexts/organization.rb
timber-1.0.4 lib/timber/contexts/organization.rb