Sha256: 13e8f26293d510a46a8cddaa25ae1ad2fda5be413241b9ddf21f2c13fbdb4d80

Contents?: true

Size: 1.33 KB

Versions: 2

Compression:

Stored size: 1.33 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.8.0
        # @api private
        alias to_s to_str

        # @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

2 entries across 2 versions & 1 rubygems

Version Path
hanami-view-1.0.0.beta1 lib/hanami/view/rendering/null_local.rb
hanami-view-0.8.0 lib/hanami/view/rendering/null_local.rb