activeinteractor 2.0.0.alpha.2.3.0 → 2.0.0.alpha.2.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c201330d4b6c13c9b409888776d669e0b1ea73fcae310f4869de55fc0bbcc500
4
- data.tar.gz: 62be913b6bee629928ba114f82a7c2a526610cab1d9978459fc8e9f4f70869b3
3
+ metadata.gz: 1db6f6df66049791647fd77a005364d34352ee6dcdc8e3e06d96bf3a0f0fe7aa
4
+ data.tar.gz: 720d4d08c58ee263bdd4b199ab89e7d8142f97cf37c87c1c60a3a81f6de6703c
5
5
  SHA512:
6
- metadata.gz: ef8f56b5ca0f79d60b9f45b3c8a1e9e394b15c15c89c98e7f747eaecf6621671020b624a0d5ba141d7948468eb83938ecd8bf62849038ad39e2f974a03bfce11
7
- data.tar.gz: ed637132df8ef4ae80843e042d780b0423480e74f5d4cd9d12128118c10e3197467cb2e31f49d2d6a62cbadfd9c83ef4abad0beb123959ddb908d2f5f39fadc2
6
+ metadata.gz: e0b72abcf5ba60f5223dea9107280e9813d084ed416dc1ab8d810ab618554b27602dc08dd8d6d671e12851fe90e94ab9552503c30c11b65294858afb447732b7
7
+ data.tar.gz: 3d7ac38cfbe1ec554033213f84a8e2a6bc253bead86f0b192376f1886e500b80f7a8715cf92c9ab448472d724ef63fb567363ebf8fd1e382c29f154f49ba284c
@@ -5,6 +5,14 @@ module ActiveInteractor
5
5
  module AttributeAssignment
6
6
  extend ActiveSupport::Concern
7
7
 
8
+ def initialize(attributes = {})
9
+ attribute_set.attributes.each do |attribute|
10
+ next unless attributes.with_indifferent_access.key?(attribute.name)
11
+
12
+ assign_attribute_value(attribute.name, attributes.with_indifferent_access[attribute.name])
13
+ end
14
+ end
15
+
8
16
  def [](attribute_name)
9
17
  read_attribute_value(attribute_name)
10
18
  end
@@ -28,16 +36,14 @@ module ActiveInteractor
28
36
  "wrong number of arguments (given #{arguments.length}, expected 1)"
29
37
  end
30
38
 
31
- assign_attribute_value(method_name, arguments.first)
39
+ assign_attribute_value(method_name.to_s.delete('=').to_sym, arguments.first)
32
40
  end
33
41
 
34
- def method_missing(method_id, *arguments)
35
- return super unless respond_to_missing?(method_id)
36
-
37
- method_name = method_id[/.*(?==\z)/m]
38
- return assignment_method_missing(method_name, *arguments) if method_name
42
+ def method_missing(method_name, *arguments)
43
+ return super unless respond_to_missing?(method_name)
44
+ return assignment_method_missing(method_name, *arguments) if method_name.to_s.end_with?('=')
39
45
 
40
- read_attribute_value(method_id)
46
+ read_attribute_value(method_name)
41
47
  end
42
48
 
43
49
  def read_attribute_value(attribute_name)
@@ -49,7 +55,7 @@ module ActiveInteractor
49
55
 
50
56
  def respond_to_missing?(method_name, _include_private = false)
51
57
  return true if attribute_set.attribute_names.include?(method_name.to_sym)
52
- return true if attribute_set.attribute_names.include?(method_name[/.*(?==\z)/m]&.to_sym)
58
+ return true if attribute_set.attribute_names.include?(method_name.to_s.delete('=').to_sym)
53
59
 
54
60
  super
55
61
  end
@@ -9,15 +9,9 @@ module ActiveInteractor
9
9
  include AttributeAssignment
10
10
  include Type::HasTypes
11
11
 
12
- attr_reader :errors
13
-
14
12
  def initialize(attributes = {})
13
+ super
15
14
  @errors = ActiveModel::Errors.new(self)
16
- attribute_set.attributes.each do |attribute|
17
- next unless attributes.with_indifferent_access.key?(attribute.name)
18
-
19
- assign_attribute_value(attribute.name, attributes.with_indifferent_access[attribute.name])
20
- end
21
15
  end
22
16
 
23
17
  def validate!
@@ -28,11 +28,10 @@ module ActiveInteractor
28
28
  @table[attribute_name.to_sym] = value
29
29
  end
30
30
 
31
- def method_missing(method_id, *arguments)
32
- method_name = method_id[/.*(?==\z)/m]
33
- return assignment_method_missing(method_name, *arguments) if method_name
31
+ def method_missing(method_name, *arguments)
32
+ return assignment_method_missing(method_name, *arguments) if method_name.to_s.end_with?('=')
34
33
 
35
- read_attribute_value(method_id)
34
+ read_attribute_value(method_name)
36
35
  end
37
36
 
38
37
  def read_attribute_value(attribute_name)
@@ -4,12 +4,14 @@ module ActiveInteractor
4
4
  module HasActiveModelErrors
5
5
  extend ActiveSupport::Concern
6
6
 
7
+ attr_reader :errors
8
+
7
9
  module ClassMethods
8
- def self.human_attribute_name(attribute, _options = {})
10
+ def human_attribute_name(attribute, _options = {})
9
11
  attribute.respond_to?(:to_s) ? attribute.to_s.humanize : attribute
10
12
  end
11
13
 
12
- def self.lookup_ancestors
14
+ def lookup_ancestors
13
15
  [self]
14
16
  end
15
17
  end
@@ -17,8 +19,6 @@ module ActiveInteractor
17
19
  included do
18
20
  extend ActiveModel::Naming
19
21
  extend ClassMethods
20
-
21
- attr_reader :errors
22
22
  end
23
23
 
24
24
  def read_attribute_for_validation(attribute_name)
@@ -13,7 +13,7 @@ module ActiveInteractor
13
13
  failed_at_output: 3
14
14
  }.freeze
15
15
 
16
- attr_reader :data, :errors
16
+ attr_reader :data
17
17
 
18
18
  class << self
19
19
  def success(data: {})
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeinteractor
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.alpha.2.3.0
4
+ version: 2.0.0.alpha.2.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Allen
@@ -88,9 +88,9 @@ licenses:
88
88
  - MIT
89
89
  metadata:
90
90
  bug_tracker_uri: https://github.com/activeinteractor/activeinteractor/issues
91
- changelog_uri: https://github.com/activeinteractor/activeinteractor/blob/v2.0.0-alpha.2.3.0/CHANGELOG.md
91
+ changelog_uri: https://github.com/activeinteractor/activeinteractor/blob/v2.0.0-alpha.2.3.2/CHANGELOG.md
92
92
  homepage_uri: https://github.com/activeinteractor/activeinteractor
93
- source_code_uri: https://github.com/activeinteractor/activeinteractor/tree/v2.0.0-alpha.2.3.0
93
+ source_code_uri: https://github.com/activeinteractor/activeinteractor/tree/v2.0.0-alpha.2.3.2
94
94
  wiki_uri: https://github.com/activeinteractor/activeinteractor/wiki
95
95
  rubygems_mfa_required: 'true'
96
96
  post_install_message:
@@ -108,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
108
  - !ruby/object:Gem::Version
109
109
  version: 1.3.1
110
110
  requirements: []
111
- rubygems_version: 3.4.19
111
+ rubygems_version: 3.4.20
112
112
  signing_key:
113
113
  specification_version: 4
114
114
  summary: Ruby interactors with ActiveModel::Validations