Class: Defi::Challenge Private

Inherits:
Object
  • Object
show all
Defined in:
lib/defi/challenge.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

This class contains a challenge to apply against an object.

Instance Method Summary collapse

Constructor Details

#initialize(method, *args) ⇒ Challenge

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initialize the challenge class.

Parameters:

  • method (#to_sym)

    The method to send to an object.

  • args (Array)

    The arguments of the method.



15
16
17
18
# File 'lib/defi/challenge.rb', line 15

def initialize(method, *args)
  @method = method.to_sym
  @args   = args
end

Instance Method Details

#to(object) ⇒ #object_id

Returns The actual value, or a raised exception.

Parameters:

  • object (#object_id)

    The object to challenge.

Returns:

  • (#object_id)

    The actual value, or a raised exception.



25
26
27
# File 'lib/defi/challenge.rb', line 25

def to(object)
  object.public_send(@method, *@args)
end

#to_hHash

Properties of the challenge.

Returns:

  • (Hash)

    The properties of the challenge.



34
35
36
37
38
39
# File 'lib/defi/challenge.rb', line 34

def to_h
  {
    method: @method,
    args:   @args
  }
end