Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
Andy Holland
@AMHOL
Yeah, not sure it adds much to the code, but it's definitely easier for humans to understand :)
Piotr Solnica
@solnic
that’s really cool, I think, we’ll see how it works :)
btw I did a sweet little thing for auto-injecting with Concord + Dry::Container
it looks like that, more or less:
class Foo
  extend AutoInject(:baz, :bar)

  def call
    bar.call(baz.call)
  end
end
which basically creates a module and sets up constructor with deps injected from a known container
and returns it, so Foo is extended with it
Andy Holland
@AMHOL
Cool, constructor injection is much better
What does AutoInject look like?
Piotr Solnica
@solnic
def AutoInject(*names)
  Module.new do |mod|
    mod.class_variable_set('@@names', names)

    def self.extended(klass)
      names = class_variable_get('@@names')

      klass.class_eval do
        include Concord.new(*names)

        def self.new(*args)
          names = ancestors.detect { |a| a.is_a?(Concord) }.names
          deps = names.map.with_index { |name, i| args[i] || SB.app.container.resolve(name) }
          super(*deps)
        end
      end
    end
  end
end
messy but works
I wrote it yesterday in anger
Andy Holland
@AMHOL
lol
Piotr Solnica
@solnic
:D
Andy Holland
@AMHOL
Nice
Piotr Solnica
@solnic
it removes helluva code from class definitions
Andy Holland
@AMHOL
You have stuff registered with call: false then?
Piotr Solnica
@solnic
and you can still easily track down what the deps are
I register them with blocks
no options
works
Andy Holland
@AMHOL
Ahh OK
Piotr Solnica
@solnic
container.register(:persistence) { Persistence.new(resolve(‘rom’)) }
things like that
Andy Holland
@AMHOL
Just with:
class Foo
  extend AutoInject(:baz, :bar)

  def call
    bar.call(baz.call)
  end
end
And the default resolver, it would call on resolution
Without the call: false option
Ahh, OK, thought you were registering procs because of the example
Piotr Solnica
@solnic
no just block syntax
btw I feel like I know enough to experiment with my custom rodakase
Andy Holland
@AMHOL
Cool, I'm not sure I like the roda-action stuff anymore, but the container would be useful
Be interesting to see what you come up with :)
Piotr Solnica
@solnic
@AMHOL actually I’m more interested in collaborating on something
it’s mostly putting pieces together but I’d prefer to collaborate and work together on something
Andy Holland
@AMHOL
@solnic Ahh, OK, more than happy to do that :smile:
Piotr Solnica
@solnic
there’s at least ~5 people who are interested in a roda-based stack
I’m not betting on lotus anymore no matter how much I love Luca and his work, it’s too OO for me :)
Andy Holland
@AMHOL
I've been thinking it would be nice to get some kind of roda skeleton setup, is that what you're thinking?
I don't mind OO, but I think Lotus is too Rails-like
Piotr Solnica
@solnic
I do mind OO when it’s full of mutable state
in general, I don’t mind dealing with objects that much
but your comment re being too railsy is true
it’s very close conceptually to rails, which was Luca’s goal anyway, to create better rails
he is very open to collaborating on shared tools so that’s great
his philosophy is really great and inline with mine so I’m sure something good can come out of that ;)
did I just say that my philosophy is great in a convoluted, implicit way? I guess I did I did ;)
Andy Holland
@AMHOL
haha
Yeah, I think he's achieved that (a better rails)
Piotr Solnica
@solnic
now I just need to make lotus use ROM
I started experimenting with rom-repository