Sha256: e819edc79c501dee7a6913f5a0ab165a586b356c46256cd54f90e611a1fc31dd

Contents?: true

Size: 736 Bytes

Versions: 1

Compression:

Stored size: 736 Bytes

Contents

module Timber
  module Contexts
    class Organization < Context
      ROOT_KEY = :organization.freeze
      VERSION = 1.freeze

      attr_reader :organization

      def id
        return @id if defined?(@id)
        @id = organization.respond_to?(:id) ? organization.id : nil
      end

      def name
        return @name if defined?(@name)
        @name = organization.respond_to?(:name) ? organization.name : nil
      end

      def valid?
        !organization.nil?
      end

      private
        def json_payload
          @json_payload ||= Macros::DeepMerger.merge({
            # order is relevant for logfmt styling
            :id => id,
            :name => name
          }, super).freeze
        end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
timberio-1.0.0.beta1 lib/timber/contexts/organization.rb