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