Sha256: fd20ffa8f3b1ffc69f29d9c0cd696360541a77a1686ab3dfd173ed904a736994

Contents?: true

Size: 1.31 KB

Versions: 13

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true

require "hanami/view/rendering/scope"
require "hanami/view/rendering/options"

module Hanami
  module View
    module Rendering
      # Rendering subscope
      #
      # @since 1.1.1
      # @api private
      #
      # @see Hanami::View::Rendering::Scope
      class Subscope < Scope
        # Implements "respond to" logic
        #
        # @return [TrueClass,FalseClass]
        #
        # @since 1.1.1
        # @api private
        #
        # @see http://ruby-doc.org/core/Object.html#method-i-respond_to_missing-3F
        def respond_to_missing?(m, _include_all)
          @locals.key?(m)
        end

        protected

        # @since 1.1.1
        # @api private
        def method_missing(m, *args, &block)
          ::Hanami::View::Escape.html(
            # FIXME: this isn't compatible with Hanami 2.0, as it extends a view
            # that we want to be frozen in the future
            #
            # See https://github.com/hanami/view/issues/130#issuecomment-319326236
            if @locals.key?(m)
              @locals[m]
            else
              super
            end
          )
        end

        private

        # @since 1.1.1
        # @api private
        def _options(options)
          Options.build(options, locals, format)
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
hanami-view-1.3.3 lib/hanami/view/rendering/subscope.rb
hanami-view-1.3.2 lib/hanami/view/rendering/subscope.rb
hanami-view-1.3.1 lib/hanami/view/rendering/subscope.rb
hanami-view-1.3.0 lib/hanami/view/rendering/subscope.rb
hanami-view-1.2.1 lib/hanami/view/rendering/subscope.rb
hanami-view-1.3.0.beta1 lib/hanami/view/rendering/subscope.rb
hanami-view-1.2.0 lib/hanami/view/rendering/subscope.rb
hanami-view-1.1.2 lib/hanami/view/rendering/subscope.rb
hanami-view-1.2.0.rc2 lib/hanami/view/rendering/subscope.rb
hanami-view-1.2.0.rc1 lib/hanami/view/rendering/subscope.rb
hanami-view-1.2.0.beta2 lib/hanami/view/rendering/subscope.rb
hanami-view-1.2.0.beta1 lib/hanami/view/rendering/subscope.rb
hanami-view-1.1.1 lib/hanami/view/rendering/subscope.rb