rthbound/pay_dirt

View on GitHub
lib/pay_dirt/result.rb

Summary

Maintainability
A
0 mins
Test Coverage
module PayDirt
  # Provides developers with a [re]usable result object for their service objects to return.
  class Result
    # The response from a use case execution
    #
    # Every use case should return a Result after it runs.
    #
    # @param [options] options_hash
    #   A hash specifying the appropriate options
    #
    # @return [PayDirt::Result]
    #   the Result instance
    #
    # @example
    #   PayDirt::Result.new(success: true, data: {})
    #   # => <PayDirt::Result>
    #
    # @public
    def initialize(options)
      @success = options[:success]
      @data    = options[:data]
    end

    # @public
    def successful?
      !!@success
    end

    # @public
    def data
      @data
    end
  end
end