Skip to content

Do not dup class and module name constants#48

Open
matas-zanevicius wants to merge 1 commit intobarsoom:masterfrom
matas-zanevicius:keyword_arguments_default_values_constants
Open

Do not dup class and module name constants#48
matas-zanevicius wants to merge 1 commit intobarsoom:masterfrom
matas-zanevicius:keyword_arguments_default_values_constants

Conversation

@matas-zanevicius
Copy link

Say I want a service that calls another service. I can inject the class as a named argument.

class MyServiceA
  method_object [:other_service]

  def call
    other_service.call
  end
end

But if I wanted to define a default service, I would end up with an anonymous class.

class MyServiceB
  def self.call
    # do stuff
  end
end

class MyServiceA
  method_object [other_service: MyServiceB]

  def call
    other_service.call
  end
end

In many cases, it is not a big problem, but it does not make much sense to duplicate a class or a module either.

This PR is a possible solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant