Skip to content

Commit

Permalink
Create ApplicationService
Browse files Browse the repository at this point in the history
  • Loading branch information
hmlON committed Jul 29, 2017
1 parent 15fd266 commit 12970b6
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions app/services/application_service.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# to call: ApplicationService.(params)
#
class ApplicationService
def self.call(*args, **kwargs)
service = new(*args, **kwargs)
service.perform
service
end

# def initialize(*args, **kwargs)
# kwargs.each do |method_name, method_value|
# define_method(method_name) { method_value }
# end
# end

def perform
raise NotImplementedError, 'This is an abstract method'
end

def errors
# http://api.rubyonrails.org/classes/ActiveModel/Errors.html
{}
end

def success?
errors.empty?
end

def failure?
!success?
end
end

0 comments on commit 12970b6

Please sign in to comment.