no_fly_list 0.7.3 → 0.7.4
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/no_fly_list/taggable_record/configuration.rb +21 -22
- data/lib/no_fly_list/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7a4d0bb308f36212383e565010061a086173ddbd9105fad575193d7abca8ffa5
|
|
4
|
+
data.tar.gz: 92772d14d0351c3a7a0d1e631d81590fb0a87e49460773cd68e78368ef55906b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 793849ef8f48b2ced0c5547187fa02cc704b05bb6ebad05b65c2d7e21780ab6b2efa6349a97ef74af310ef49afa28c79506ee431f45b74613bc9038482ebf970
|
|
7
|
+
data.tar.gz: 963dd7b6d64a7b159bc4085a6ea80f3641730a108dc820a91bb9201b8e636ac5705e07f4a561a6fa1089d377866ef9fbf0c55d2018796f1bd8a9750573584c85
|
|
@@ -82,8 +82,6 @@ module NoFlyList
|
|
|
82
82
|
|
|
83
83
|
# Creates a new tagging class with appropriate configuration
|
|
84
84
|
def create_tagging_class(setup, base_class)
|
|
85
|
-
setup.context.to_s.singularize
|
|
86
|
-
|
|
87
85
|
Class.new(base_class) do
|
|
88
86
|
self.table_name = "#{setup.taggable_klass.table_name.singularize}_taggings"
|
|
89
87
|
|
|
@@ -173,21 +171,26 @@ module NoFlyList
|
|
|
173
171
|
end
|
|
174
172
|
|
|
175
173
|
# Set up tagging class associations
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
174
|
+
# Guard belongs_to to prevent STI subclasses from overwriting
|
|
175
|
+
# the base class association on a shared tagging class
|
|
176
|
+
tagging_klass = setup.tagging_class_name.constantize
|
|
177
|
+
existing_taggable = tagging_klass.reflect_on_association(:taggable)
|
|
178
|
+
if existing_taggable.nil? || existing_taggable.class_name == setup.taggable_klass.name
|
|
179
|
+
tagging_klass.class_eval do
|
|
180
|
+
belongs_to :tag,
|
|
181
|
+
class_name: setup.tag_class_name,
|
|
182
|
+
foreign_key: "tag_id"
|
|
183
|
+
|
|
184
|
+
belongs_to :taggable,
|
|
185
|
+
class_name: setup.taggable_klass.name,
|
|
186
|
+
foreign_key: "taggable_id"
|
|
187
|
+
|
|
188
|
+
validates :tag, :taggable, :context, presence: true
|
|
189
|
+
validates :tag_id, uniqueness: {
|
|
190
|
+
scope: %i[taggable_id context],
|
|
191
|
+
message: "has already been tagged on this record in this context"
|
|
192
|
+
}
|
|
193
|
+
end
|
|
191
194
|
end
|
|
192
195
|
end
|
|
193
196
|
|
|
@@ -238,11 +241,7 @@ module NoFlyList
|
|
|
238
241
|
# Define helper methods module for this context
|
|
239
242
|
helper_module = Module.new do
|
|
240
243
|
define_method :create_and_set_proxy do |instance_variable_name, setup|
|
|
241
|
-
tag_model =
|
|
242
|
-
setup.tag_class_name.constantize
|
|
243
|
-
else
|
|
244
|
-
self.class.const_get("#{self.class.name}Tag")
|
|
245
|
-
end
|
|
244
|
+
tag_model = setup.tag_class_name.constantize
|
|
246
245
|
|
|
247
246
|
proxy = TaggingProxy.new(
|
|
248
247
|
self,
|
data/lib/no_fly_list/version.rb
CHANGED