alba 3.7.4 → 3.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 19dd24ca7012ad65ea2c69fbd5f7fe9e0fe8931ac2a04320a74292d9d033943d
4
- data.tar.gz: 95595afe6847cbaa2dde39d5d287d5d6ce82ec28182a3c12153d437dd140147e
3
+ metadata.gz: 2ff1f7d9c2cf5b49ee88a9cf864e3a66251ccdb502515a1ea91c64837f84d22d
4
+ data.tar.gz: d26b6be0d948d848ba35f216392f9bafe3581925816cc9ee9eeaf651a3face3b
5
5
  SHA512:
6
- metadata.gz: a0ff2aa000c80343b9bd02d0cbbe8789477aa4adf1a357fac87600c0b7821f992eec1986848ce97b81c678bb5e4ecbadfa50a076eb0a015caa9fbf7a814492db
7
- data.tar.gz: 676be0a714bf6b5325b0e6412fcce1abac2f1d517b48dde00bdc4d8ca4ce5fa10838d735cede7f893dee8291001ef8331841160a7374a02da267d87859066ff6
6
+ metadata.gz: b4b114df3e7e26bf2249f6f683efd1c856594cea376d6b8e33078f1cb9e3810132cf4cb120cfbc6682a556f84ca40115e157f09376c8a81af0160e20efcb2e23
7
+ data.tar.gz: 314f599a9564c053ed653178dd743291cb9125965e8bef7146bed5c049ec44568a40bb1b201df700fe0025e344ae4586af769a377db4f2a50527875aaf2c2c04
data/CHANGELOG.md CHANGED
@@ -6,6 +6,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## 3.8.0 2025-08-02
10
+
11
+ ### Added
12
+
13
+ - add support for ignoring key when using proc for on_error [#450](https://github.com/okuramasafumi/alba/pull/450)
14
+ - Thank you, @mainmethod
15
+
16
+ ### Note
17
+
18
+ This change is supposed to be released as 3.8.0 with the change in 3.7.4, but I overlooked this commit. So 3.8.0 is essentially the same as 3.7.4, just making it clear that this version adds a new feature.
19
+
9
20
  ## 3.7.4 2025-07-24
10
21
 
11
22
  ### Fixed
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [![Gem Version](https://badge.fury.io/rb/alba.svg)](https://badge.fury.io/rb/alba)
4
4
  [![CI](https://github.com/okuramasafumi/alba/actions/workflows/main.yml/badge.svg)](https://github.com/okuramasafumi/alba/actions/workflows/main.yml)
5
5
  [![codecov](https://codecov.io/gh/okuramasafumi/alba/branch/main/graph/badge.svg?token=3D3HEZ5OXT)](https://codecov.io/gh/okuramasafumi/alba)
6
- [![Maintainability](https://api.codeclimate.com/v1/badges/fdab4cc0de0b9addcfe8/maintainability)](https://codeclimate.com/github/okuramasafumi/alba/maintainability)
6
+ [![Maintainability](https://qlty.sh/gh/okuramasafumi/projects/alba/maintainability.svg)](https://qlty.sh/gh/okuramasafumi/projects/alba)
7
7
  ![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/okuramasafumi/alba)
8
8
  ![GitHub](https://img.shields.io/github/license/okuramasafumi/alba)
9
9
  [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](CODE_OF_CONDUCT.md)
@@ -371,6 +371,7 @@ You can pass a Hash to the resource for internal use. It can be used as "flags"
371
371
  ```ruby
372
372
  class UserResource
373
373
  include Alba::Resource
374
+
374
375
  attribute :name do |user|
375
376
  params[:upcase] ? user.name.upcase : user.name
376
377
  end
@@ -1229,6 +1230,7 @@ The block receives five arguments, `error`, `object`, `key`, `attribute` and `re
1229
1230
  ```ruby
1230
1231
  class ExampleResource
1231
1232
  include Alba::Resource
1233
+
1232
1234
  on_error do |error, object, key, attribute, resource_class|
1233
1235
  if resource_class == MyResource
1234
1236
  ['error_fallback', object.error_fallback]
@@ -1526,6 +1528,7 @@ Alba supports serializing JSON in a layout. You need a file for layout and then
1526
1528
  ```ruby
1527
1529
  class FooResource
1528
1530
  include Alba::Resource
1531
+
1529
1532
  layout file: 'my_layout.json.erb'
1530
1533
  end
1531
1534
  ```
@@ -1543,6 +1546,7 @@ In case you don't want to have a file for layout, Alba lets you define and apply
1543
1546
  ```ruby
1544
1547
  class FooResource
1545
1548
  include Alba::Resource
1549
+
1546
1550
  layout inline: proc {
1547
1551
  {
1548
1552
  header: 'my header',
@@ -1559,6 +1563,7 @@ You can also use a Proc which returns String, not a Hash, for an inline layout.
1559
1563
  ```ruby
1560
1564
  class FooResource
1561
1565
  include Alba::Resource
1566
+
1562
1567
  layout inline: proc {
1563
1568
  %({
1564
1569
  "header": "my header",
@@ -1659,6 +1664,7 @@ In `attribute` block we can call instance method so we can improve the code belo
1659
1664
  ```ruby
1660
1665
  class FooResource
1661
1666
  include Alba::Resource
1667
+
1662
1668
  # other attributes
1663
1669
  attribute :created_at do |foo|
1664
1670
  foo.created_at.strftime('%m/%d/%Y')
@@ -1671,6 +1677,7 @@ end
1671
1677
 
1672
1678
  class BarResource
1673
1679
  include Alba::Resource
1680
+
1674
1681
  # other attributes
1675
1682
  attribute :created_at do |bar|
1676
1683
  bar.created_at.strftime('%m/%d/%Y')
@@ -1694,6 +1701,7 @@ end
1694
1701
  class FooResource
1695
1702
  include Alba::Resource
1696
1703
  include SharedLogic
1704
+
1697
1705
  # other attributes
1698
1706
  attribute :created_at do |foo|
1699
1707
  format_time(foo.created_at)
@@ -1707,6 +1715,7 @@ end
1707
1715
  class BarResource
1708
1716
  include Alba::Resource
1709
1717
  include SharedLogic
1718
+
1710
1719
  # other attributes
1711
1720
  attribute :created_at do |bar|
1712
1721
  format_time(bar.created_at)
@@ -1738,6 +1747,7 @@ end
1738
1747
  class FooResource
1739
1748
  include Alba::Resource
1740
1749
  extend AlbaExtension
1750
+
1741
1751
  # other attributes
1742
1752
  formatted_time_attributes :created_at, :updated_at
1743
1753
  end
@@ -1745,6 +1755,7 @@ end
1745
1755
  class BarResource
1746
1756
  include Alba::Resource
1747
1757
  extend AlbaExtension
1758
+
1748
1759
  # other attributes
1749
1760
  formatted_time_attributes :created_at, :updated_at
1750
1761
  end
@@ -1760,6 +1771,7 @@ When we `extend AlbaExtension` like above, it's not available in inline associat
1760
1771
  class BarResource
1761
1772
  include Alba::Resource
1762
1773
  extend AlbaExtension
1774
+
1763
1775
  # other attributes
1764
1776
  formatted_time_attributes :created_at, :updated_at
1765
1777
 
@@ -1775,6 +1787,7 @@ In this case, we can use [helper](#helper) instead of `extend`.
1775
1787
  ```ruby
1776
1788
  class BarResource
1777
1789
  include Alba::Resource
1790
+
1778
1791
  helper AlbaExtension # HERE!
1779
1792
  # other attributes
1780
1793
  formatted_time_attributes :created_at, :updated_at
@@ -1811,6 +1824,7 @@ The typical code looks like this:
1811
1824
  ```ruby
1812
1825
  class FooResource
1813
1826
  include Alba::Resource
1827
+
1814
1828
  attributes :id
1815
1829
  end
1816
1830
  FooResource.new(foo).serialize
data/lib/alba/resource.rb CHANGED
@@ -609,6 +609,7 @@ module Alba
609
609
  def helper(mod = @_helper || Module.new, &block)
610
610
  mod.module_eval(&block) if block
611
611
  extend mod
612
+
612
613
  @_helper = mod
613
614
  end
614
615
 
data/lib/alba/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Alba
4
- VERSION = '3.7.4'
4
+ VERSION = '3.8.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alba
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.7.4
4
+ version: 3.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - OKURA Masafumi