Sha256: 6783a523a8f2e8bd6044f840e7d4c68d6facca883918b25d75607f366c8628dc

Contents?: true

Size: 1.26 KB

Versions: 1

Compression:

Stored size: 1.26 KB

Contents

require 'hanami/utils/basic_object'

module Hanami
  module View
    module Rendering
      # Null local
      #
      # @since 0.7.0
      #
      # @see Hanami::View::Rendering#local
      class NullLocal < Utils::BasicObject
        # @since 0.7.0
        # @api private
        TO_STR = "".freeze

        # @since 0.7.0
        # @api private
        def initialize(local)
          @local = local
        end

        # @since 0.7.0
        def all?
          false
        end

        # @since 0.7.0
        def any?
          false
        end

        # @since 0.7.0
        def empty?
          true
        end

        # @since 0.7.0
        def nil?
          true
        end

        # @since 0.7.0
        # @api private
        def to_str
          TO_STR
        end

        # @since 0.7.0
        # @api private
        def method_missing(m, *)
          if m.match(/\?\z/)
            false
          else
            self.class.new("#{ @local }.#{ m }")
          end
        end

        private

        # @since 0.7.0
        # @api private
        def respond_to_missing?(method_name, include_all)
          true
        end

        # @since 0.7.0
        # @api private
        def __inspect
          " :#{ @local }"
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hanami-view-0.7.0 lib/hanami/view/rendering/null_local.rb