Last active
September 4, 2024 08:52
-
-
Save ghn/5ebaf90d0d7d9bc366af9c521e550ef9 to your computer and use it in GitHub Desktop.
Rails service definition
This file contains hidden or 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
# A | |
module Document | |
class ActionService | |
def initialize(a, b) | |
@a = a | |
@b = b | |
end | |
def call | |
compute | |
end | |
end | |
end | |
# B | |
module DocumentService | |
class Action | |
def initialize(a, b) | |
@a = a | |
@b = b | |
end | |
def call | |
compute | |
end | |
end | |
end | |
# C | |
module DocumentService | |
def action(a, b) | |
compute | |
end | |
end | |
# D | |
class DocumentService | |
def self.action(a, b) | |
compute | |
end | |
end | |
# E | |
module Document | |
class ActionService | |
class << self | |
def call(a, b) | |
new(a).call(b) | |
end | |
end | |
def initialize(a) | |
@a = a | |
end | |
def call(b) | |
service_instance.call(b) | |
end | |
def service_instance | |
@service_instance ||= ..whatever.. | |
end | |
end | |
end | |
# F | |
module DocumentService | |
class Action | |
def call(a, b) | |
compute | |
end | |
end | |
end | |
# G | |
module DocumentService | |
class Create | |
def self.call(a, b) | |
compute | |
end | |
private def whatever | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment