All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
render_serialized_json
now works withroot_key
andmeta
#398
- Add transform_keys caching #402
Alba.serialize
now works with heterogeneous collection #396
- TypedAttribute now respects prefer_resource_method! #391
- Rails integration with
ActionController::API
- Add ostruct as gemspec dependency to be prepared for ruby 3.3.5. #386
- Add
ArrayOfString
andArrayOfInteger
type #378
- Add the ability to change key for metadata #362
- Fixed warning when
location
option is given torender json:
in Rails #348
- Fixed a bug where methods such as
test
orparams
cannot be used as attribute name #344 - Remove redundant code
This release contains an important bug fix that can cause data corruption. If you're using Ruby 3, it's highly recommended to upgrade to v3.0.0 If you're using Ruby 2, please upgrade to v2.4.2 that contains bug fix only as soon as possible.
- Custom type #333
- Prefer resource method #323
- Multithread bug No PR
- This is a critical bug that can cause data corruption.
- Drop support for Ruby 2 series No PR
- Fix the bug of resource name inference for classes whose name end with "Serializer" No PR
- Fix the bug of resource name inference No PR
- Add compatibility option for key #304
- It now infers resource name from Serializer #309
Alba.serialize
is easier to use for multiple root keys #311- Gives access to params in nested_attribute #312
- Thank you, @GabrielErbetta
- Rails integration to set default inflector #298
- Fix cascade not working with association and inheritance #300
- Drop support of Ruby 2.6
- Add
select
method for filtering attributes #270 - Allow ConditionalAttribute with 2-arity proc to reject nil attributes #273
- Add support for proc resource in one polymorphic associations #281
- Deprecate
inference
related methods in favor of a unifiedinflector
interface. Deprecated methods are:Alba.enable_inference!
,Alba.disable_inference!
, andAlba.inferring
. UseAlba.inflector = :active_support/:dry
orAlba.inflector = SomeInflector
to enable. UseAlba.inflector = nil
to disable. UseAlba.inflector
to check if enabled.
- All Hash-related methods now return String keys instead of Symbol keys.
This affects all users, but you can use
deep_symbolize_keys
in Rails environment if you prefer Symbol keys, orwith_indifferent_access
to support both String and Symbol keys. Some DSLs that take key argument such ason_nil
andon_error
, are also affected. - Remove deprecated methods:
Resource#to_hash
,Resource.ignoring
,Alba.on_nil
,Alba.on_error
,Alba.enable_root_key_transformation!
andAlba.disable_root_key_transformation!
- If using
transform_keys
, the default inflector is no longer set by default d02245c8 To retain this functionality in Rails, add an initializer with the following:Alba.enable_inference!(with: :active_support)
- Passing an initial object to proc function in associations #209
- Allow association resource to be Proc #213
collection_key
to serialize collection into a Hash #119- params is now overridable #227
- Key transformation now cascades #232
- nested attribute #237
- Implement
as_json
#249
- fix the bug where nesting is empty string and invalid
handle_error
now raises the same error- let Rails implicitly call
to_json
- [Feat] Support instance method as an attribute
- [Fix] Explicitly raise error when inference is disabled
- [Improve]
enable_inference!
now takes inflector as argument - [Improve]
transform_keys
now accepts:snake
and:none
- [Deprecate]
to_hash
is special method and should not be used - [Deprecate]
ignoring
in favor ofattributes
overriding - [Deprecate]
Alba.on_nil
,Alba.on_error
andAlba.enable_root_key_transformation!
- [Feat] Add nil handler
- [Feat] Implement layout feature
- [Improve] if option now works with Symbol
- [Improve] Add an alias for serialize
- [Improve] Deprecation warning now printed with caller
- [Feat] Add a config method to set encoder directly
- [Feat] Implement
meta
method and option for metadata - [Feat] Add
root_key
option toResource#serialize
- [Feat] Enable setting key for collection with
root_key
- [Feat] Add
Resource.root_key
andResource.root_key!
- [Feat]
Alba.serialize
now infers resource class - [Deprecated]
Resource.key
andResource.key!
are deprecated
- [Perf] Improve performance for
many
[641d8f9] - [Feat] Add custom inflector feature (#126) [ad73291]
- #126
- Thank you @wuarmin !
- [Feat] Support params in if condition [6e9915e]
- [Fix] fundamentally broken "circular association control" [fbbc9a1]
- [Fix] multiple word key inference [6c18e73]
- #120
- Thank you @alfonsojimenez !
- [Feat] Add
Alba.enable_root_key_transformation!
[f172839] - [Feat] Implement type validation and auto conversion [cbe00c7]
- [Feat] Implement circular associations control [71e1543]
- [Feat] Support :oj_rails backend [76e519e]
- [Fix] Don't cache resource class for
Alba.serialize
[9ed5253] - [Improve] Warn when
ActiveSupport
orOj
are absent [d3ab3eb] - [Fix] Delete unreachable
to_hash
method on Association [1ba1f90] - [Fix] Stringify key before transforming [b4eb79e]
- [Misc] Support Ruby 2.5.0 and above, not 2.5.7 and above [43f1d17]
- [Fix] Remove accidentally added
p
debug [5d0324b]
This is the first major release of Alba and it includes so many features. To see all the features you can have a look at README.