alba 3.3.2 → 3.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 61d5619d6222aee091fc2401da8a274a2d8aa5beebf3d8626f2bc82c6c24e89f
4
- data.tar.gz: c6368081ef1701ec0d7444c9e544071d03ab5ae706fc344c9d52b027833efa4b
3
+ metadata.gz: d3168959e9726c35e28faf0f027dd78010b4b0cf5ead0564b8fa8a7f32e5bf84
4
+ data.tar.gz: b9cab46abe11f69ef40ef15d3cc673a279a6f1ab12ab8a8b908250a8462f65e8
5
5
  SHA512:
6
- metadata.gz: d303cd41e825e8c9bbdfd9213d9e76b99969b348e1943ebee1deb2d9ee469338dcfcab5e5fb3661915f602e1e9bed532ac96add4a387e843e1e74f356e4aae1b
7
- data.tar.gz: 73cc7d1b8236c33c4f3a24f633e7029ec59f288b57fe5668da1363c926ea0d87062170440b2aef3332ada59515b8c11c9548f195137ea63507ca06705ec9547a
6
+ metadata.gz: 8d5b3c0513e7f706d484fdc19c8423fc6261bd7b670eee46009b0cf15b9b47f8bdfc14041937a57f15e75c679ad3073fa84ecaf1bcc782ab0615fdebd141a6cc
7
+ data.tar.gz: 017b40ee4d711a50bcd2c74719a0a4a27b4965058cfb8f37382765a84b7400fc78af754fb98b0d4aeb7ba5c935656b3d61687e9c0784a09a047269fbd2e7356f
data/CHANGELOG.md CHANGED
@@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [3.3.3] 2024-11-09
10
+
11
+ ### Fixed
12
+
13
+ - TypedAttribute now respects prefer_resource_method! [#391](https://github.com/okuramasafumi/alba/pull/391)
14
+
9
15
  ## [3.3.2] 2024-10-30
10
16
 
11
17
  ### Fixed
data/Gemfile CHANGED
@@ -11,7 +11,7 @@ gem 'ffaker', require: false # For testing
11
11
  gem 'minitest', '~> 5.14' # For test
12
12
  gem 'railties', require: false # For Rails integration testing
13
13
  gem 'rake', '~> 13.0' # For test and automation
14
- gem 'rubocop', '~> 1.67.0', require: false # For lint
14
+ gem 'rubocop', '~> 1.68.0', require: false # For lint
15
15
  gem 'rubocop-gem_dev', '>= 0.3.0', require: false # For lint
16
16
  gem 'rubocop-md', '~> 1.0', require: false # For lint
17
17
  gem 'rubocop-minitest', '~> 0.36.0', require: false # For lint
data/lib/alba/resource.rb CHANGED
@@ -239,12 +239,12 @@ module Alba
239
239
  Alba.transform_key(key, transform_type: @_transform_type)
240
240
  end
241
241
 
242
- def fetch_attribute(obj, key, attribute) # rubocop:disable Metrics/CyclomaticComplexity
242
+ def fetch_attribute(obj, key, attribute) # rubocop:disable Metrics
243
243
  value = case attribute
244
244
  when Symbol then fetch_attribute_from_object_and_resource(obj, attribute)
245
245
  when Proc then instance_exec(obj, &attribute)
246
246
  when Alba::Association then yield_if_within(attribute.name.to_sym) { |within| attribute.to_h(obj, params: params, within: within) }
247
- when TypedAttribute then attribute.value(obj)
247
+ when TypedAttribute then attribute.value { |attr| fetch_attribute(obj, key, attr) }
248
248
  when NestedAttribute then attribute.value(object: obj, params: params, within: @within)
249
249
  when ConditionalAttribute then attribute.with_passing_condition(resource: self, object: obj) { |attr| fetch_attribute(obj, key, attr) }
250
250
  # :nocov:
@@ -18,10 +18,9 @@ module Alba
18
18
  end
19
19
  end
20
20
 
21
- # @param object [Object] target to check and convert type with
22
21
  # @return [String, Integer, Boolean] type-checked or type-converted object
23
- def value(object)
24
- v = object.__send__(@name)
22
+ def value
23
+ v = yield(@name)
25
24
  result = @type.check(v)
26
25
  result ? v : @type.convert(v)
27
26
  rescue TypeError
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.3.2'
4
+ VERSION = '3.3.3'
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alba
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.2
4
+ version: 3.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - OKURA Masafumi
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2024-10-30 00:00:00.000000000 Z
10
+ date: 2024-11-09 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: ostruct