Class: Haml::Helpers::ErrorReturn

Inherits:
Object
  • Object
show all
Defined in:
lib/haml/helpers.rb

Overview

An object that raises an error when #to_s is called. It’s used to raise an error when the return value of a helper is used when it shouldn’t be.

Instance Method Summary collapse

Constructor Details

#initialize(message) ⇒ ErrorReturn

Returns a new instance of ErrorReturn.

Parameters:

  • message (String)

    The error message to raise when #to_s is called



17
18
19
# File 'lib/haml/helpers.rb', line 17

def initialize(message)
  @message = message
end

Instance Method Details

#inspectString

Returns A human-readable string representation.

Returns:

  • (String)

    A human-readable string representation



29
30
31
# File 'lib/haml/helpers.rb', line 29

def inspect
  "Haml::Helpers::ErrorReturn(#{@message.inspect})"
end

#to_sObject

Raises an error.

Raises:



24
25
26
# File 'lib/haml/helpers.rb', line 24

def to_s
  raise Haml::Error.new(@message)
end