Module: Lotus::ClassMethods Private

Defined in:
lib/lotus/interactor.rb

Overview

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

Since:

  • 0.5.0

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(interactor) ⇒ Object

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.

Since:

  • 0.5.0



453
454
455
456
457
458
459
460
# File 'lib/lotus/interactor.rb', line 453

def self.extended(interactor)
  interactor.class_eval do
    include Utils::ClassAttribute

    class_attribute :exposures
    self.exposures = Utils::Hash.new
  end
end

Instance Method Details

#expose(*instance_variable_names) ⇒ Object

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.

Expose local instance variables into the returing value of #call

Examples:

Expose instance variable


class Signup
  include Lotus::Interactor
  expose :user

  def initialize(params)
    @params = params
    @user   = User.new(@params[:user])
  end

  def call
    # ...
  end
end

result = Signup.new(user: { name: "Luca" }).call

result.user   # => #<User:0x007fa85c58ccd8 @name="Luca">
result.params # => NoMethodError

Parameters:

  • instance_variable_names (Symbol, Array<Symbol>)

    one or more instance variable names

See Also:

Since:

  • 0.5.0



491
492
493
494
495
# File 'lib/lotus/interactor.rb', line 491

def expose(*instance_variable_names)
  instance_variable_names.each do |name|
    exposures[name] = "@#{ name }"
  end
end