Sha256: d194a1e016b096034d868ec7736a4b655436898e7c4a85b31f314929c2317f62

Contents?: true

Size: 662 Bytes

Versions: 2

Compression:

Stored size: 662 Bytes

Contents

module SimpleService
  class Organizer

    include ServiceBase::InstanceMethods
    extend ServiceBase::ClassMethods

    attr_accessor :context

    def initialize(context={})
      @context = context

      ArgumentValidator.new(
        context: context,
        expects: expects,
        returns: returns,
        commands: commands
      ).execute

      setup_execute_chain
    end

    def self.commands(*args)
      @commands = args
    end

    def commands
      self.class.instance_variable_get('@commands')
    end

    def execute
      commands.each do |command|
        @context.merge!(command.new(context).execute)
      end
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
simple_service-1.0.2 lib/simple_service/organizer.rb
simple_service-1.0.1 lib/simple_service/organizer.rb