Sha256: 8edebf38f7714f96c7e8968735cac4aa5e29a2ed49685408406f85e576b316b7

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

module Timber
  module Contexts
    module TemplateRenders
      # Because this is a sub type we extend Context
      class ActionViewSpecific < Context
        ROOT_KEY = :action_view.freeze
        VERSION = 1.freeze

        class << self
          def json_shell(&_block)
            TemplateRender.json_shell { super }
          end
        end

        attr_reader :event

        def initialize(event)
          # Initialize should be as fast as possible since it is executed inline.
          # Hence the lazy methods below.
          @event = event
          super()
        end

        def cache_hits
          @cache_hits ||= payload[:cache_hits]
        end

        def count
          @count ||= payload[:count]
        end

        def layout
          @layout ||= payload[:layout]
        end

        private
          def json_payload
            @json_payload ||= Macros::DeepMerger.merge({
              :cache_hits => cache_hits,
              :count => count,
              :layout => layout
            }, super).freeze
          end

          def payload
            event.payload
          end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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