Skip to content

Releases: taylorthurlow/interaktor

v0.6.0.pre2

15 Jan 20:38
17d6823

Choose a tag to compare

v0.6.0.pre2 Pre-release
Pre-release

Please see the notes for 0.6.0.pre for details pertaining to the prerelease in general.


Breaking changes

  • Support for the the normalization feature provided by ActiveModel::Attributes::Normalization has been removed. The normalization module also includes ActiveModel::Dirty, which provides methods like <attr>_changed?, changes, and <attr>_changes, which interfere/override attribute methods that could otherwise be defined in an interaktor.

v0.6.0.pre

13 Nov 00:39
78971bf

Choose a tag to compare

v0.6.0.pre Pre-release
Pre-release

This is a pre-release of v0.6.0. I'm not expecting any further changes, but I'm trying to test things out in a production environment before committing to the full release.


This release is a significant change from prior versions - attribute definition is no longer done with the Dry::Schema builder. Instead, they are now done with the ActiveModel attribute DSL, which is the same DSL used internally by ActiveRecord. Validations also come along with this change, which are the same validations you would find on an ActiveRecord model.

The primary motivation for this change is not that I dislike Dry::Schema (over the years using this gem it is not my favorite, but it works well for this use case), but that it became clear that more complex attribute schemas just did not function correctly. This gem relied on a built-in "extension" (called info) which allows introspection into a schema to determine which schema attributes are required and which are optional - this extension just does not function (raises an exception) for certain complex schemas (like ones that use logical OR or XOR).

Pre-1.0 is the time to make this sort of change so I decided to cut losses and switch to ActiveModel, which is a little more tried and true, and suits this use case a little better. Along with this comes some cooler features like value normalization (with activemodel >= 8.1), primitive attribute type definitions and value coercion, and the entire suite of validation predicates most Ruby developers have used before in ActiveRecord.


Breaking changes

  • Attribute definitions now use activemodel. See the README for examples. The minimum version of activemodel allowed is 7.0.9 - earlier versions do not initialize correctly - I don't think versions earlier than this were intended to be used outside of an ActiveRecord model context, so it's not entirely surprising they don't work.
  • Some attribute names are now completely disallowed, and defining them will raise an exception. Currently the list of disallowed attribute names is just the list of instance method names that already exist on Interaktor::Attributes, the superclass used internally by Interaktor to manage attributes and their values. This list is defined at Interaktor::Attributes::DISALLOWED_ATTRIBUTE_NAMES. Examples of now-disallowed attribute names that may have been used commonly are errors, attributes, attribute_names, class, method, methods, changes, changed, model_name, hash, object_id, and send.
  • An exception will be raised if an input, success, or failure block is defined more than once on an interaktor.

v0.5.1

10 Nov 18:32
b5d1089

Choose a tag to compare

Fixed

  • An issue where, in some contexts, optional input attributes would raise an exception when attempting to read them within the interaktor's #call.

v0.5.0

07 Nov 21:09
2238e14

Choose a tag to compare

Minor breaking changes in this release.

Calling an interaktor now returns an Interaktor::Interaction instance, instead of an Interaktor::Context.

Impacts to normal usage of the gem

  • Attempting to access input arguments on an Interaction after the interaction has finished executing will raise NoMethodError
  • Attempting to access success arguments on an Interaction after the interaction has finished executing, having resulted in a failure will raise NoMethodError
  • Attempting to access failure arguments on an Interaction after the interaction has finished executing, having resulted in a success will raise NoMethodError
  • Calling an interaktor with any input arguments that are not explicitly defined as input arguments on the interaktor class will now raise an exception, where previously they would have been silently ignored.

Other impacts which are less likely to impact normal gem usage

  • This context object was an OpenStruct wrapper, which is being removed as a default gem in Ruby 3.5, and is also generally recommended to be avoided for performance concerns. The new Interaction class is not an OpenStruct, and OpenStruct is no longer a dependency of this gem.
  • Organizers have their own interaction instance to track its own input, success, and failure arguments - previously, the same context object would have been passed between the organized interaktors, but that is no longer the case - each organized interaktor creates its own interaction from scratch, based on the prior interaktor's interaction data.
  • Attempting to access success or failure arguments on an Interaction before the interaction has finished executing will raise NoMethodError
  • Calling #failure? or #success? on an interaction before the interaction has completed execution will raise an exception

v0.4.0

18 Feb 19:03
1e58250

Choose a tag to compare

Added

  • An ensure_hook method has been added which will run a piece of code after normal interaktor execution, regardless of whether or not the interaktor ran successfully. The method accepts a symbol (corresponding to an instance method name to call), or a block (containing code to run). These hooks, like others, will run in the order in which they are defined. (@nicolas-heinig, #16)

v0.3.0

02 Jul 00:52
86d81fa

Choose a tag to compare

Buckle up, we've got some breaking changes.

Fixed

  • Some methods that previously raised NoMethodError exceptions now raise NotImplementedError exceptions. This is done in an effort to denote these methods as "abstract" methods. NoMethodError is a subclass of Exception and not StandardError so it is generally a bad idea to raise them without understanding the consequences, especially in a library such as this.

Changed

  • Attributes of all kinds (input, success, and failure attributes) are now defined using dry-schema's schema DSL. Check out the revised README for more details. This change should prevent me from having to reinvent the wheel for validating attributes in general.
  • Organizers now pass their input attributes into all organized interaktors' input attributes.
  • Organized interaktors now pass their success attributes into all successive organized interaktors' input attributes.
    • For example, when an organizer organizes interaktors A, B, C, and D, in that order, A's success attributes may be used as input attributes of B, C, and D. C's success attributes may be used as input attributes of D.
  • Some exception messages are now benefiting from increased excellence.

Added

  • Explicit support for Ruby 3.0.

v0.2.0

02 Nov 23:42
95f7ea3

Choose a tag to compare

Fixed

  • Interaktors which have success attributes defined will now cause an exception to be raised if their execution finishes completely without a call to #success!.

Changed

  • Organizers now pass their own attributes to the first interaktor, and each interaktor passes its attributes (required, optional, and success) to the next interaktor in the chain. When passing attributes between interaktors, attributes unknown to the receiving interaktor are dropped. See the organizer section of the README for more detail.
  • Providing unknown options to the failure and success DSL methods will now raise an exception.
  • Passing a non-hash argument to .call or .call! will raise a more helpful exception.

Added

  • Added custom error classes for the various error cases instead of raising RuntimeErrors.

v0.1.5

29 Sep 23:58
8232d68

Choose a tag to compare

Fixed

  • Using #success! to return early from an interaktor should no longer prevent organizers from working properly.

Changed

  • An error will now be raised when you call an interaktor and an attribute is provided that is not defined on the interaktor class.

Added

  • Added default option to the optional DSL method, which can be optionally provided to set a default value for an optional attribute, which will be set if the attribute is not set when called

v0.1.4

24 Sep 21:51
0d20b56

Choose a tag to compare

Changed

  • Removed the public accessor for context now that the entire interface for an interaktor's context should consist of explicitly defined attributes. This is a breaking change as it is no longer backwards-compatible with Interactor. No major version bump because this is definitely not 1.0 yet, and I can't imagine anyone is using this at this point.
  • Relaxed zeitwerk dependency version from ~> 2.3.1 to ~> 2.0

Added

  • Added #success! method for early-exit functionality, and their accompanying success attribute DSL method

v0.1.3

13 Jul 17:41
7241e75

Choose a tag to compare

This is the first public release. It can act as a drop-in replacement for Interactor, assuming you change the module name references to Interaktor.