property_sets 3.7.1 → 3.9.0

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: '08caa288aeb6e948f670a9d93176e7899952b3a62df76493e33918de4c4e52ab'
4
- data.tar.gz: d46e8b42e761deb230eebaa3ee64e8b24115c82c9913fb3927a97cacc8ebcb50
3
+ metadata.gz: da83a6695b48bf923b2971cc108ad9ab636c9b6f66e50d631f1973601d454bf5
4
+ data.tar.gz: c4415b9eecc381a94af2bfbcfbe3a9837e4576526648b91a05fb05bc51241207
5
5
  SHA512:
6
- metadata.gz: 574137f6c3004b8eca710df7784a7089f0a76791ea6afcb059ca6a9ae0d7c7495c3b452934cebdc43b40c2b60f5726495707b4990efc728172ae3dfa2fd7e838
7
- data.tar.gz: 5e366367388d47381ce6566916a1a59588142daeb3523c1c479ad2657d476bf08f4725a2d8fa2e41d354b1eb69ada4c26bb9165a0b80b871a709afd0d96e606b
6
+ metadata.gz: 89ebdbcb3d8123601c60d4aacee7c4f33b10da3eaafc9406d53457aa941742bcf5348516a9105bf3716196b00e42c9917fa3f2beb4ef5cc88cf4f1aeec58909c
7
+ data.tar.gz: 5a0c62442a970bb6eb5e43a94b701671306febe920b513bdefcd98c8213884ae29f3a02af9fcaffe5c71fb20517d5bb65a7ae17119929bce9668203c34ace4f9
@@ -36,7 +36,7 @@ module PropertySets
36
36
  :class_name => property_class.name,
37
37
  :autosave => true,
38
38
  :dependent => :destroy,
39
- :inverse_of => self.name.underscore.to_sym,
39
+ :inverse_of => self.name.demodulize.underscore.to_sym,
40
40
  }.merge(options)
41
41
 
42
42
  # TODO: should check options are compatible? warn? raise?
@@ -126,12 +126,12 @@ module PropertySets
126
126
  end
127
127
  end
128
128
 
129
- def save(*args)
130
- each { |p| p.save(*args) }
129
+ def save(...)
130
+ each { |p| p.save(...) }
131
131
  end
132
132
 
133
- def save!(*args)
134
- each { |p| p.save!(*args) }
133
+ def save!(...)
134
+ each { |p| p.save!(...) }
135
135
  end
136
136
 
137
137
  def protected?(arg)
@@ -137,9 +137,10 @@ module PropertySets
137
137
  end
138
138
 
139
139
  def owner_class=(owner_class_name)
140
- @owner_class_sym = owner_class_name.underscore.to_sym
141
- belongs_to owner_class_sym
142
- validates_presence_of owner_class_sym
140
+ @owner_class_sym = owner_class_name.to_s.demodulize.underscore.to_sym
141
+
142
+ belongs_to owner_class_sym, class_name: owner_class_name
143
+ validates_presence_of owner_class_sym, class_name: owner_class_name
143
144
  validates_uniqueness_of :name, :scope => owner_class_key_sym, :case_sensitive => false
144
145
  attr_accessible owner_class_key_sym, owner_class_sym if defined?(ProtectedAttributes)
145
146
  end
@@ -1,3 +1,3 @@
1
1
  module PropertySets
2
- VERSION = "3.7.1"
2
+ VERSION = "3.9.0"
3
3
  end
data/lib/property_sets.rb CHANGED
@@ -9,20 +9,21 @@ end
9
9
 
10
10
  module PropertySets
11
11
  def self.ensure_property_set_class(association, owner_class_name)
12
- const_name = "#{owner_class_name}#{association.to_s.singularize.camelcase}".to_sym
12
+ const_name = "#{owner_class_name.demodulize}#{association.to_s.singularize.camelcase}"
13
+ namespace = owner_class_name.deconstantize.safe_constantize || Object
13
14
 
14
- unless Object.const_defined?(const_name)
15
+ unless namespace.const_defined?(const_name, false)
15
16
  property_class = Class.new(ActiveRecord::Base) do
16
17
  include PropertySets::PropertySetModel::InstanceMethods
17
18
  extend PropertySets::PropertySetModel::ClassMethods
18
19
  end
19
20
 
20
- Object.const_set(const_name, property_class)
21
+ namespace.const_set(const_name, property_class)
21
22
 
22
23
  property_class.owner_class = owner_class_name
23
24
  property_class.owner_assoc = association
24
25
  end
25
26
 
26
- Object.const_get(const_name)
27
+ namespace.const_get(const_name.to_s)
27
28
  end
28
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: property_sets
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.7.1
4
+ version: 3.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Morten Primdahl
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-29 00:00:00.000000000 Z
11
+ date: 2023-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -16,20 +16,20 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '4.2'
19
+ version: '5.0'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '6.2'
22
+ version: '7.1'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: '4.2'
29
+ version: '5.0'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '6.2'
32
+ version: '7.1'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: json
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -132,7 +132,7 @@ homepage: http://github.com/zendesk/property_sets
132
132
  licenses:
133
133
  - MIT
134
134
  metadata: {}
135
- post_install_message:
135
+ post_install_message:
136
136
  rdoc_options: []
137
137
  require_paths:
138
138
  - lib
@@ -140,15 +140,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
140
140
  requirements:
141
141
  - - ">="
142
142
  - !ruby/object:Gem::Version
143
- version: '2.4'
143
+ version: '2.7'
144
144
  required_rubygems_version: !ruby/object:Gem::Requirement
145
145
  requirements:
146
146
  - - ">="
147
147
  - !ruby/object:Gem::Version
148
148
  version: '0'
149
149
  requirements: []
150
- rubygems_version: 3.1.6
151
- signing_key:
150
+ rubygems_version: 3.0.3.1
151
+ signing_key:
152
152
  specification_version: 4
153
153
  summary: Property sets for ActiveRecord.
154
154
  test_files: []