Sha256: 2b0871f056b2d52e413db7de74fb2cc3ad054cd4cf549e59db75684c2f6e1ed3

Contents?: true

Size: 793 Bytes

Versions: 4

Compression:

Stored size: 793 Bytes

Contents

module Zertico
  class Interactor
    def perform(params)
      fail!('You should overwrite this method!')
    end

    def rollback
      true
    end

    def inject_instances(instances = {})
      instances.each do |instance_name, instance_variable|
        instance_variable_set("@#{instance_name}", instance_variable)
      end
    end

    def get_instances
      instance_variables.inject({}) do |instances, instance_variable|
        instances[instance_variable.to_s.gsub('@', '')] = instance_variable_get(instance_variable)
        instances
      end
    end

    protected

    def self.interface_name
      self.to_s.chomp('Interactor').split('::').last
    end

    private

    def fail!(message = '')
      raise Zertico::Exceptions::RollbackException, message
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
zertico-2.0.0.beta.1 lib/zertico/interactor.rb
zertico-2.0.0.alpha.3 lib/zertico/interactor.rb
zertico-2.0.0.alpha.2 lib/zertico/interactor.rb
zertico-2.0.0.alpha.1 lib/zertico/interactor.rb