Sha256: 1c7d695a306f915fcd36d1b8445cd046969e784cbee672d933b1532ec4c2072d
Contents?: true
Size: 879 Bytes
Versions: 13
Compression:
Stored size: 879 Bytes
Contents
require 'rubygems' require 'simple_service' class ConcatAnotherName < SimpleService::Command expects :first_name, :last_name returns :name def call self.name = "#{first_name} #{last_name}" end end class CreateAnotherHelloString < SimpleService::Command expects :name returns :hello def call self.hello ||= '' self.hello += "#{name}, say hello world!" end end class SayHelloMultipleTimes < SimpleService::Organizer expects :first_name, :last_name, :num_times returns :hello commands ConcatAnotherName, CreateAnotherHelloString # overriding the #call method on the organizer allows # you to do things like loop and call the service commands # multiple times def call num_times.times do super end end end result = SayHelloMultipleTimes.new(first_name: 'Ruby', last_name: 'Gem', num_times: 3).call puts result[:hello]
Version data entries
13 entries across 13 versions & 1 rubygems