Class: PayDirt::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/pay_dirt/result.rb

Overview

Provides developers with a [re]usable result object for their service objects to return.

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ PayDirt::Result

The response from a use case execution

Every use case should return a Result after it runs.

Examples:

PayDirt::Result.new(success: true, data: {})
# => <PayDirt::Result>

Parameters:

  • options_hash (options)

    A hash specifying the appropriate options



19
20
21
22
# File 'lib/pay_dirt/result.rb', line 19

def initialize(options)
  @success = options[:success]
  @data    = options[:data]
end

Instance Method Details

#dataObject



30
31
32
# File 'lib/pay_dirt/result.rb', line 30

def data
  @data
end

#successful?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/pay_dirt/result.rb', line 25

def successful?
  !!@success
end