active_type
active_type copied to clipboard
Make any Ruby object quack like ActiveRecord
If you call a method like `attribute_was` on your original model object, then this method call causes a `MutationAfterCastError`. `attribute_was` is not changing the model so this method call shouldn't...
Suppose an enum defined as follows: ```ruby class Payment < ActiveType::Object enum state: { stale: 0, loading: 1, failed: 2, ready: 3 }, _default: :stale end ``` Then in Rails...
ActiveType imitates regular Rails models almost perfectly. However, I've run into a situation where that is not the case: - `active_type (2.5.0)` - `gettext_i18n_rails (1.12.0)` While `MyModel.human_attribute_name(:my_attr)` works fine on...
I noticed that the `validate_numericality_of` matcher from [shoulda_matcher](https://github.com/thoughtbot/shoulda-matchers/blob/6f4de5ad6d0d09486c2c713fb1a0bf38169d399e/lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb) does not work with an instance of an `ActiveType` record. The reason for this is a [add_disallow_non_numeric_value_matcher](https://github.com/thoughtbot/shoulda-matchers/blob/6f4de5ad6d0d09486c2c713fb1a0bf38169d399e/lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb#L374C11-L374C49) check in the `shoulda_matcher` gem....
Hi! Hope you're doing well. Using `active_type` with custom serialization breaks because calling `read_attribute_before_type_cast` on a `ActiveType::Object` returns `nil`. I've managed to work around the problem by implementing the following...