granite 0.14.1 → 0.14.2

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: c6a9f12a8fab90e99e863a20803400744a5eb9f0393d4fd8e9242e6d2eca542b
4
- data.tar.gz: 54c451903bc4b9b9cebbe7fd07201e8492f0fbaab301d2cbae05e4f7ecc9c6e5
3
+ metadata.gz: 9d4056c068ce20c44a4951e8f2c6c52be5d37913900c79a32041627c08bc09d9
4
+ data.tar.gz: 00127702e26bd46b17778e6ead007acce5b59cfbfd1a3b01d315c8286b6b6d36
5
5
  SHA512:
6
- metadata.gz: bae2c1833fe6f5e04f31a3974c6d7d94afe0a71dca159b73fd53350d30c97fcac26b67330484ade77ee08e1b1bbce0d14cba44e37408dcdde0cccf9085927152
7
- data.tar.gz: 618880a543e9c33b448990ebbf3947fab1bbf1ddcad7797dc22f4c22e6f7fbc025ffdfd224b8d321c091bcac07517ad222938cdb68fc76a63e320cc5a5f17768
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
- if self.class._subject.blank?
36
- super
37
- return
38
- end
43
+ return super unless self.class.subject? # rubocop:disable Lint/ReturnInVoidContext
39
44
 
40
- reflection = self.class.reflect_on_association(self.class._subject)
45
+ reflection = self.class.subject_reflection
41
46
  attributes = extract_initialize_attributes(args)
42
47
 
43
48
  subject_attributes = extract_subject_attributes!(attributes, reflection)
@@ -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.added?(error.attribute, error)
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)
@@ -1,3 +1,3 @@
1
1
  module Granite
2
- VERSION = '0.14.1'.freeze
2
+ VERSION = '0.14.2'.freeze
3
3
  end
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.1
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-08-26 00:00:00.000000000 Z
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: []