-
-
Save ka8725/27321acc3d22a7d954505d974e414a9e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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