Class: Metybur::Method::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/metybur/method.rb

Instance Method Summary collapse

Constructor Details

#initialize(attributes, callback) ⇒ Result

Returns a new instance of Result.



5
6
7
8
# File 'lib/metybur/method.rb', line 5

def initialize(attributes, callback)
  @attributes = attributes
  @callback = callback
end

Instance Method Details

#publishObject



10
11
12
# File 'lib/metybur/method.rb', line 10

def publish
  instance_eval(&@callback) if @callback
end

#resultObject Also known as: raise_errors



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/metybur/method.rb', line 14

def result
  error = @attributes[:error]
  if error
    fail(
      Metybur::MethodError,
      "error: #{error[:error]}, reason: #{error[:reason]}, details: #{error[:details]}"
    )
  else
    @attributes[:result]
  end
end