Skip to content

Latest commit

 

History

History
45 lines (37 loc) · 1.28 KB

upgrade_notes.md

File metadata and controls

45 lines (37 loc) · 1.28 KB

Upgrade notes

Upgrade from 1.0.0 to 2.0.0

The test helper ensure_method_delegators has been removed. If you used it, just remove its usage.

If you do not use wrappers, there is nothing further you need to do to upgrade.

The wrapper interface changed. With version 1.0 you had to implement methods prefixed with before_ and after_. The return value of before-hooks where used as arguments to the next wrapper, while the return value of after-hooks was passed down to the previous wrapper. E.g:

module Wrapper
  class Validator
    def before_find(id:)
      raise ArgumentError if id.nil?
      {id: id}
    end
  end

  class ModelMapper
    def after_find(return_value, **_kwargs)
      Model::User.new(return_value)
    end
  end
end

In version 2.0 there are no before- and after-methods anymore. Instead you provide one method that wraps around the next wrapper or the strategy. You need to name the wrapper methods exactly as they are named in your strategy and you call yield to call the next wrapper. E.g:

module Wrapper
  class Validator
    def find(id:)
      raise ArgumentError if id.nil?
      yield(id: id)
    end
  end
  
  class ModelMapper
    def find(id:)
      return_value = yield(id: id)
      Model::User.new(return_value)
    end
  end
end