Class: Dialers::Wrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/dialers/wrapper.rb

Overview

This class is just a convenience to this:

class Anything
  def api_caller
    @api_caller ||= ApiCaller.new
  end
end

Instead, you can wrap it like this:

class Anything < Dialers::Wrapper
  api_caller { ApiCaller.new }
end

The major reason of the existence of this class is to provide a place to add future improvements like automatic injection of callers within Rails based on conventions and methods and patterns that may arise in the future.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#api_callerObject (readonly)

Returns the value of the `api_caller` as defined by the api_caller class method


32
33
34
# File 'lib/dialers/wrapper.rb', line 32

def api_caller
  @api_caller
end

Class Method Details

.api_caller(&block) ⇒ Object

Defines the api caller instance to use on all wrappers.

api_caller { ApiCaller.new }

25
26
27
28
29
# File 'lib/dialers/wrapper.rb', line 25

def self.api_caller(&block)
  define_method(:api_caller) do
    @api_caller ||= block.call
  end
end