adomokos / light-service

Series of Actions with an emphasis on simplicity.
MIT License
837 stars 67 forks source link

Remove Key Aliases #136

Closed adomokos closed 5 years ago

adomokos commented 6 years ago

At one point, we needed key aliasing for our actions to avoid 1 line Actions. You can find more about it here.

Now that we have Orchestrator functionality in Organizers, I think this feature is obsolete. We could accomplish the same thing with an execute actions.

So instead of doing this:

class SomeAction
   aliases :my_key => :key_alias
end

We could do this:

class SomeOrganizer
  extend LightService::Organizer

  def self.call(id)
    with(:id => id).reduce(actions)
  end

  def self.actions
    [SomeAction1,
     SomeAction2,
     execute(->(ctx) { ctx[:key_alias] = ctx[:my_key] }),
     AnotherAction]
  end
end

See how the execute block now is responsible for aliasing.

Let me know if you're NOT OK with deprecating (and eventually removing in 1.0) key aliasing.

adomokos commented 6 years ago

A deprecation warning would be a great start for this, before the feature is removed.

gee-forr commented 5 years ago

Only saw this now... just want to point out that I do use key_aliases, and it would be great if they could stick around, especially as Orchestrators are now deprecated...

adomokos commented 5 years ago

I'll leave this, but before hooks or even a simple execute block could be used to this. I don't think there is enough support to remove it, I'll keep it in there.