granite 0.14.1 → 0.14.2
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 +4 -4
- data/lib/granite/action/subject.rb +10 -5
- data/lib/granite/action.rb +1 -1
- data/lib/granite/represents/attribute.rb +5 -0
- data/lib/granite/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d4056c068ce20c44a4951e8f2c6c52be5d37913900c79a32041627c08bc09d9
|
4
|
+
data.tar.gz: 00127702e26bd46b17778e6ead007acce5b59cfbfd1a3b01d315c8286b6b6d36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 611de3a2edf7e5b7e42d2da1b06f35cef0a49c3ff7712c3bffe57a4f0deecd7e3454216dd13617914d211825a34764b223ad8b780537a9d4d0122c7aa0e0e429
|
7
|
+
data.tar.gz: 5273870b5a1a2c0d93deef1a21d3c8f3d40bda27e19588199a6301544d7d454df50243dbd4bedf766988ddf37502e177c727f998d5fabbbfeef4761bd395d31d
|
@@ -29,15 +29,20 @@ module Granite
|
|
29
29
|
|
30
30
|
self._subject = name
|
31
31
|
end
|
32
|
+
|
33
|
+
def subject?
|
34
|
+
_subject.present?
|
35
|
+
end
|
36
|
+
|
37
|
+
def subject_reflection
|
38
|
+
reflect_on_association(_subject)
|
39
|
+
end
|
32
40
|
end
|
33
41
|
|
34
42
|
def initialize(*args)
|
35
|
-
|
36
|
-
super
|
37
|
-
return
|
38
|
-
end
|
43
|
+
return super unless self.class.subject? # rubocop:disable Lint/ReturnInVoidContext
|
39
44
|
|
40
|
-
reflection = self.class.
|
45
|
+
reflection = self.class.subject_reflection
|
41
46
|
attributes = extract_initialize_attributes(args)
|
42
47
|
|
43
48
|
subject_attributes = extract_subject_attributes!(attributes, reflection)
|
data/lib/granite/action.rb
CHANGED
@@ -72,7 +72,7 @@ module Granite
|
|
72
72
|
else
|
73
73
|
def merge_errors(other_errors)
|
74
74
|
other_errors.each do |error|
|
75
|
-
errors.import(error) unless errors.
|
75
|
+
errors.import(error) unless errors.messages[error.attribute].include?(error.message)
|
76
76
|
end
|
77
77
|
end
|
78
78
|
end
|
@@ -1,6 +1,10 @@
|
|
1
1
|
module Granite
|
2
2
|
module Represents
|
3
3
|
class Attribute < ActiveData::Model::Attributes::Attribute
|
4
|
+
types = {}
|
5
|
+
types[ActiveRecord::Enum::EnumType] = String if defined?(ActiveRecord)
|
6
|
+
TYPES = types.freeze
|
7
|
+
|
4
8
|
delegate :writer, :reader, :reader_before_type_cast, to: :reflection
|
5
9
|
|
6
10
|
def initialize(*_args)
|
@@ -84,6 +88,7 @@ module Granite
|
|
84
88
|
|
85
89
|
attribute_type = reference.type_for_attribute(name.to_s)
|
86
90
|
|
91
|
+
return TYPES[attribute_type.class] if TYPES.key?(attribute_type.class)
|
87
92
|
return Granite::Action::Types::Collection.new(convert_type_to_value_class(attribute_type.subtype)) if attribute_type.respond_to?(:subtype)
|
88
93
|
|
89
94
|
convert_type_to_value_class(attribute_type)
|
data/lib/granite/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: granite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.14.
|
4
|
+
version: 0.14.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Toptal Engineering
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
@@ -316,8 +316,8 @@ dependencies:
|
|
316
316
|
- - "~>"
|
317
317
|
- !ruby/object:Gem::Version
|
318
318
|
version: '0.15'
|
319
|
-
description:
|
320
|
-
email:
|
319
|
+
description:
|
320
|
+
email:
|
321
321
|
executables: []
|
322
322
|
extensions: []
|
323
323
|
extra_rdoc_files: []
|
@@ -400,7 +400,7 @@ homepage: https://github.com/toptal/granite
|
|
400
400
|
licenses:
|
401
401
|
- MIT
|
402
402
|
metadata: {}
|
403
|
-
post_install_message:
|
403
|
+
post_install_message:
|
404
404
|
rdoc_options: []
|
405
405
|
require_paths:
|
406
406
|
- lib
|
@@ -416,7 +416,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
416
416
|
version: '0'
|
417
417
|
requirements: []
|
418
418
|
rubygems_version: 3.2.33
|
419
|
-
signing_key:
|
419
|
+
signing_key:
|
420
420
|
specification_version: 4
|
421
421
|
summary: Another business actions architecture for Rails apps
|
422
422
|
test_files: []
|