Skip to content

Releases: AaronLasseigne/active_interaction

v2.1.1

04 Aug 15:14
Compare
Choose a tag to compare

Fixed

  • #296: Fixed a bug that silently converted invalid lazy default values to
    nil instead of raising an InvalidDefaultError.

v2.1.0

30 Jul 18:20
Compare
Choose a tag to compare
  • #295: Added given? predicate method to see if an input was passed to run.

v2.0.1

28 May 15:44
Compare
Choose a tag to compare

Fixed

  • #286: Change file filter to check for rewind instead of eof?.
  • #289: Actually removed model filter, which was deprecated in v1.6.0.

v2.0.0

06 May 17:00
Compare
Choose a tag to compare

Changed

  • #250: Replaced symbolic errors with Rails 5-style detailed errors.
  • #269: Prevented proc defaults from being eagerly evaluated.
  • #264: Renamed model filter to object.
  • #213: Remove transaction support. Database transactions will need to be
    handled manually now.
  • #214: Results are returned from invalid outcomes.
  • #164: Changed the hash filter to use hashes with indifferent access.
  • #236: Changed the file filter to accept anything that responds to eof?.

Security

  • #215: Rather than symbolizing keys all hashes now use indifferent access.
    This takes care of potential but unlikely DoS attacks noted in #163.

Upgrading

Please read through the Changed section for a full list of changes.

The contents of the execute method are no longer wrapped in a transaction. You
can manually add a transaction if you need it by using
ActiveRecord::Base.transaction. We've also removed the transaction method since
it no longer has a use.

# v1.6
class Example < ActiveInteraction::Base
  # This is the default.
  transaction true

  def execute
    # ...
  end
end

# v2.0
class Example < ActiveInteraction::Base
  def execute
    ActiveRecord::Base.transaction do
      # ...
    end
  end
end

Symbolic errors should now be added with add instead of add_sym. Additionally,
you can view the errors with details instead of symbolic. This aligns with the
direction Rails is taking.

# v1.6
class Example < ActiveInteraction::Base
  def execute
    errors.add_sym :base, :invalid
    errors.add_sym :base, :custom, '...'
  end
end
Example.run.errors.symbolic
# => {:base=>[:invalid,:custom]}

# v2.0
class Example < ActiveInteraction::Base
  def execute
    errors.add :base, :invalid
    errors.add :base, :custom, message: '...'
  end
end
Example.run.errors.details
# => {:base=>[{:error=>:invalid},{:error=>:custom,:message=>'...'}]}

In the hash filter we've stopped converting all inputs to symbols and instead we
now convert the hash to a hash with indifferent access. This means hash keys will
display as strings instead of symbols.

class Example < ActiveInteraction::Base
  hash :options,
    strip: false

  def execute
    options.keys
  end
end

# v1.6
Example.run!(options: { enable: true })
# => [:enable]

# v2.0
Example.run!(options: { enable: true })
# => ["enable"]

We added the ability to return results from invalid interactions. Setting the result to
nil was unnecessary. The right way to check for validity is to use valid?. This change
allows you to return something from an interaction even if there are errors. This can be
very useful when updating an existing record.

class Example < ActiveInteraction::Base
  def execute
    errors.add(:base)
    'something'
  end
end

# v1.6
outcome = Example.run
outcome.valid?
# => false
outcome.result
# => nil

# v2.0
outcome = Example.run
outcome.valid?
# => false
outcome.result
# => "something"

When setting a default with a Proc is is no longer eagerly evaluated.

class Example < ActiveInteraction::Base
  boolean :flag,
    default: -> {
      puts 'defaulting...'
      true
    }

  def execute
    puts 'executing...'
  end
end

# v1.6
# defaulting...
Example.run
# executing...

# v2.0
Example.run
# defaulting...
# executing...

v1.6.0

06 May 16:56
Compare
Choose a tag to compare

Added

  • Added object as an alias for model.
  • Added symbol support to add.
  • Added details as an alternative to symbolic.

Changed

  • Deprecated model in favor of object.
  • Deprecated add_sym in favor of add.
  • Deprecated transaction.
  • Deprecated symbolic in favor of details.

v1.5.1

29 Apr 20:43
Compare
Choose a tag to compare

Fixed

  • #265: Allow nil inputs for interface and model filters.
  • #256: Improve error messages for nested invalid values.

v1.5.0

05 Feb 22:06
Compare
Choose a tag to compare

Added

  • #248: Add has_attribute? support to an instance of an interaction.

Fixed

  • #248: Fix support for simple_form gem.

v1.4.1

13 Dec 04:22
Compare
Choose a tag to compare

Fixed

  • #244: Fix improperly adding load paths to I18n.

v1.4.0

10 Dec 23:17
Compare
Choose a tag to compare

Changed

  • #239: Accept ActiveRecord::Relation objects as array inputs.

v1.3.1

10 Dec 22:03
Compare
Choose a tag to compare

Fixed

  • #235: Fix a bug that prevented custom translations from loading.
  • #224: Fix a bug that incorrectly inferred plural class names for filters
    inside arrays.