serradura/u-case

Change Micro::Case::Result#transitions [Breaking change]

serradura opened this issue · 0 comments

Replace the key value by result into success and failure hash/key.

module UserTodos
  Create = Micro::Cases.flow([
    Users::Authenticate,
    Todos::Create
  ])
end

result = UserTodos.call({
  email: 'rodrigo.serradura@gmail.com',
  token: '12345678',
  description: 'buy milk'
})

result.transitions == [
  {
    use_case: {
      class: Users::Authenticate,
      attributes: { email: 'rodrigo.serradura@gmail.com', token: '12345678' }
    }
    success: {
      type: :ok, result: { user: <User...> }
    },
    accessible_attributes: [:email, :token, :description]
  },
  {
    use_case: {
      class: Todos::Create,
      attributes: {
        user: <User...>, description: 'buy milk'
      }
    }
    success: {
      type: :ok, result: { todo: <Todo...> }
    },
    accessible_attributes: [:email, :token, :description, :user]
  }
]