Sha256: 5918c831c73af3c031dfef9a055ba421acdf70e86b447281c360664ff2b1f8ec

Contents?: true

Size: 1.42 KB

Versions: 22

Compression:

Stored size: 1.42 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
        # @api private
        def all?
          false
        end

        # @since 0.7.0
        # @api private
        def any?
          false
        end

        # @since 0.7.0
        # @api private
        def empty?
          true
        end

        # @since 0.7.0
        # @api private
        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

22 entries across 22 versions & 1 rubygems

Version Path
hanami-view-1.3.3 lib/hanami/view/rendering/null_local.rb
hanami-view-1.3.2 lib/hanami/view/rendering/null_local.rb
hanami-view-1.3.1 lib/hanami/view/rendering/null_local.rb
hanami-view-1.3.0 lib/hanami/view/rendering/null_local.rb
hanami-view-1.2.1 lib/hanami/view/rendering/null_local.rb
hanami-view-1.3.0.beta1 lib/hanami/view/rendering/null_local.rb
hanami-view-1.2.0 lib/hanami/view/rendering/null_local.rb
hanami-view-1.1.2 lib/hanami/view/rendering/null_local.rb
hanami-view-1.2.0.rc2 lib/hanami/view/rendering/null_local.rb
hanami-view-1.2.0.rc1 lib/hanami/view/rendering/null_local.rb
hanami-view-1.2.0.beta2 lib/hanami/view/rendering/null_local.rb
hanami-view-1.2.0.beta1 lib/hanami/view/rendering/null_local.rb
hanami-view-1.1.1 lib/hanami/view/rendering/null_local.rb
hanami-view-1.1.0 lib/hanami/view/rendering/null_local.rb
hanami-view-1.1.0.rc1 lib/hanami/view/rendering/null_local.rb
hanami-view-1.1.0.beta3 lib/hanami/view/rendering/null_local.rb
hanami-view-1.1.0.beta2 lib/hanami/view/rendering/null_local.rb
hanami-view-1.1.0.beta1 lib/hanami/view/rendering/null_local.rb
hanami-view-1.0.1 lib/hanami/view/rendering/null_local.rb
hanami-view-1.0.0 lib/hanami/view/rendering/null_local.rb