Class: Dommy::ErrorValue

Inherits:
Object
  • Object
show all
Defined in:
lib/dommy/promise.rb

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, name: "Error") ⇒ ErrorValue

Returns a new instance of ErrorValue.



5
6
7
8
# File 'lib/dommy/promise.rb', line 5

def initialize(message = nil, name: "Error")
  @message = message.to_s
  @name = name
end

Instance Method Details

#__js_get__(key) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/dommy/promise.rb', line 10

def __js_get__(key)
  case key
  when "message"
    @message
  when "name"
    @name
  else
    nil
  end
end

#to_sObject



21
22
23
24
25
# File 'lib/dommy/promise.rb', line 21

def to_s
  return @name if @message.empty?

  "#{@name}: #{@message}"
end