-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
Description
Service
# lib/service.rb
module Service
extend ActiveSupport::Concern
included do
def self.call(*args)
new(*args).call
end
end
endWith Attributes
# Gemfile
gem 'virtus'
# lib/attributable_service.rb
module AttributableService
extend ActiveSupport::Concern
included do
include Service
include Virtus.model
end
endUsing
module Users
class Create
include AttributableService
attribute :params, Hash
attribute :password, String
def call
user.password = password
user.save
user
end
private
def user
@user ||= User.new(params)
end
endUsers::Create.call(params: params, password: 'asdf')Reactions are currently unavailable