store_model 1.5.0 → 1.5.1

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: 5cc3ab45857fd85292b845bb4b7dccfe0c3df64e4baebb1387599800f16caafe
4
- data.tar.gz: a772d44ba83b7236992f21b854a1b7a76ef353c2b32083f996a9c78306402468
3
+ metadata.gz: 11081c035b30aac60161c2efaa4c629faf80aee154135d71cd9d1723ac0f96ea
4
+ data.tar.gz: 7ccd368264fd10a0731b81d30f708d1187f5b4571dc0e27cc374e650ab8c5d91
5
5
  SHA512:
6
- metadata.gz: d2ece15986e487b1eb67c6a81dc8c2a6173f726f7be72ee531328b9fe79271a30d6cd608d0d51d4d32ffd59316e7f961c946445d83f686099dc9992dc256f990
7
- data.tar.gz: e9e4512c14d680360db6fb57b0e9a96676a62377656057ab4a530730c38c91826f7603bf5ea11e46e1c8673c2d0c93d48a6c1347350db34a6c2cd9f6753fd9a2
6
+ metadata.gz: 9842ac11b144fe8bde05bb50e0d91b6301450a8bd3f67cfdb3beca09c7d806568dc40994db42eebe929c01eca83ce8762a622eeea512bdfa0e04b92458ed33ba
7
+ data.tar.gz: 88044a2f28e0edf8a6babfd7935d1e89af2df45e6b9c831227cfabc9346e89421d53ce19e8dfcdf44c96efe93d3bf6faf28ccdf3251fb167391ccba38eef81e5
@@ -27,11 +27,21 @@ module StoreModel
27
27
  when Types::Many
28
28
  define_association_setter_for_many(association, options)
29
29
  end
30
+
31
+ define_attr_accessor_for_destroy(association, options)
30
32
  end
31
33
  end
32
34
 
33
35
  private
34
36
 
37
+ def define_attr_accessor_for_destroy(association, options)
38
+ return unless options&.dig(:allow_destroy)
39
+
40
+ attribute_types[association.to_s].model_klass.class_eval do
41
+ attr_accessor :_destroy
42
+ end
43
+ end
44
+
35
45
  def define_association_setter_for_many(association, options)
36
46
  define_method "#{association}_attributes=" do |attributes|
37
47
  assign_nested_attributes_for_collection_association(association, attributes, options)
@@ -7,6 +7,8 @@ module StoreModel
7
7
  # Implements ActiveModel::Type::Value type for handling an array of
8
8
  # StoreModel::Model
9
9
  class ManyBase < ActiveModel::Type::Value
10
+ attr_reader :model_klass
11
+
10
12
  # Returns type
11
13
  #
12
14
  # @return [Symbol]
@@ -6,6 +6,8 @@ module StoreModel
6
6
  module Types
7
7
  # Implements ActiveModel::Type::Value type for handling an instance of StoreModel::Model
8
8
  class OneBase < ActiveModel::Type::Value
9
+ attr_reader :model_klass
10
+
9
11
  # Returns type
10
12
  #
11
13
  # @return [Symbol]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module StoreModel # :nodoc:
4
- VERSION = "1.5.0"
4
+ VERSION = "1.5.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: store_model
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - DmitryTsepelev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-16 00:00:00.000000000 Z
11
+ date: 2023-01-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord