class Perfume::Service
Public: The pattern is simple, our Service
is a struct with init arguments that additionally is callable. It also comes with class level ‘call` method that executes stuff on new instance of the object.
Public Class Methods
call(args = {}, &block)
click to toggle source
Public: Shorthand to instantionante with arguments and perform call in one shot. You should actually always intend to use this method as it’s easier to mock in testing.
# File lib/perfume/service.rb, line 15 def self.call(args = {}, &block) new(args).call(&block) end
Public Instance Methods
call(&block)
click to toggle source
Public: Implement this one on your own. Your logic goes here.
# File lib/perfume/service.rb, line 20 def call(&block) raise NotImplementedError end
Protected Instance Methods
exec(*args, &block)
click to toggle source
# File lib/perfume/service.rb, line 30 def exec(*args, &block) Shell::Exec.call(*args, &block) end
system_call(*args, &block)
click to toggle source
# File lib/perfume/service.rb, line 26 def system_call(*args, &block) Shell::SystemCall.call(*args, &block) end