Skip to content

Instantly share code, notes, and snippets.

@ka8725 ka8725/service.rb Secret
Created Nov 9, 2017

Embed
What would you like to do?
class BaseService
def self.inherited(superclass)
Object.send(:define_method, superclass.name) do |*params|
superclass.new(*params).call
end
end
end
class UnfollowObjectService < BaseService
def initialize(object, user)
@object = object
@user = user
end
def call
Following.where(object: @object, follower: @user).update_all(deleted_at: Time.current)
end
end
UnfollowObjectService(Tweet.find(1), User.find(2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.