hot-glue 0.5.5 → 0.5.6
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61b8c21f0bf630a68d9861b8bb70141ce7fe0da0a0f1ae71c3bb4e69da6b081d
|
4
|
+
data.tar.gz: 865d633fe279b4db0b2927801c82ec6de1ab630b4ffb7d24ffc539dfbb56d44d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26901af291d1db0f028b14e320ed6c66908c90d94777c559bdba508c4e111b651357531f9fffc468cc419fbe16dda1d9bb6b86777c6e8f840631c4dfb7239e3d
|
7
|
+
data.tar.gz: 69775a6b4a31b142e1683c2017d2b85c1fda1f7350bb4b954948a0b06bfbb990578bed98c0eedce1534e10ad78aa44b87d27deecf027f017184aa731319c62cb
|
data/README.md
CHANGED
@@ -568,17 +568,25 @@ Please note that this example would produce non-functional code, so you would ne
|
|
568
568
|
|
569
569
|
Hawk a foreign key that is not the object's owner to within a specified scope.
|
570
570
|
|
571
|
-
Assuming a Pet belong_to a :human, when building an Appointments scaffold,
|
571
|
+
Assuming a Pet belong_to a :human, when building an Appointments scaffold,
|
572
|
+
you can hawk the `pet_id` to the current human's pets. (Whoever is the authentication object.)
|
572
573
|
|
574
|
+
The hawk has two forms: a short-form (`--hawk=key`) and long form (`--hawk=key{scope})
|
575
|
+
|
576
|
+
The short form looks like this. It presumes there is a 'pets' association from `current_user`
|
573
577
|
`--hawk=pet_id`
|
574
578
|
|
579
|
+
(The long form equivalent of this would be `--hawk=pet_id{current_user.pets}`)
|
580
|
+
|
575
581
|
This is covered in [Example #3 in the Hot Glue Tutorial](https://jfb.teachable.com/courses/hot-glue-in-depth-tutorial/lectures/38584014)
|
576
582
|
|
577
|
-
To hawk to a scope that is not the currently authenticated user, use
|
583
|
+
To hawk to a scope that is not the currently authenticated user, use the long form with `{...}`
|
584
|
+
to specify the scope. Be sure to note to add the association name itself, like `users`:
|
578
585
|
|
579
|
-
`--hawk=user_id{current_user.family}`
|
586
|
+
`--hawk=user_id{current_user.family.users}`
|
580
587
|
|
581
|
-
This would hawk the Appointment's `user_id` key to any users who are within the scope of the
|
588
|
+
This would hawk the Appointment's `user_id` key to any users who are within the scope of the
|
589
|
+
current_user's has_many association (so, for any other "my" family, would be `current_user.family.users`).
|
582
590
|
|
583
591
|
This is covered in [Example #4 in the Hot Glue Tutorial](https://jfb.teachable.com/courses/hot-glue-in-depth-tutorial/lectures/38787505)
|
584
592
|
|
@@ -905,6 +913,12 @@ Child portals have the headings omitted automatically (there is a heading identi
|
|
905
913
|
|
906
914
|
# VERSION HISTORY
|
907
915
|
|
916
|
+
#### 2023-01-02 - v0.5.6
|
917
|
+
- Changes the long-form of the hawk specifier to require you to use the has_many of the relationship you are hawking (previously, it was assumed). See Hawk for details
|
918
|
+
- Adds "Regenerate me" comment to top of all generated controllers
|
919
|
+
- Change behavior of pluralization. Now, you can use an `inflections.rb` file and non-standard pluralization will be respected.
|
920
|
+
|
921
|
+
|
908
922
|
#### 2022-12-27 - v0.5.5
|
909
923
|
|
910
924
|
- Experimental support for Tailwind. Note I was not able to get Tailwind actually working in my app, and I'm not sure about how to think about the many flavors of Tailwind (all of which seem to be paid?). If anyone can lend a hand, the objects are now cleanly refactored so that the CSS logic is separated.
|
@@ -78,9 +78,9 @@ module HotGlue
|
|
78
78
|
@hawk_alarm = ""
|
79
79
|
hawk_schema.each do |hawk_key,hawk_definition|
|
80
80
|
hawk_root = hawk_definition[0]
|
81
|
-
hawk_scope = hawk_definition[1]
|
81
|
+
# hawk_scope = hawk_definition[1]
|
82
82
|
begin
|
83
|
-
eval("hawk_root
|
83
|
+
eval("hawk_root").find(modified_params[hawk_key.to_s])
|
84
84
|
rescue ActiveRecord::RecordNotFound => e
|
85
85
|
@hawk_alarm << "You aren't allowed to set #{hawk_key.to_s} to #{modified_params[hawk_key.to_s]}. "
|
86
86
|
modified_params.tap { |hs| hs.delete(hawk_key.to_s) }
|
@@ -139,9 +139,7 @@ module HotGlue
|
|
139
139
|
|
140
140
|
if @hawk_keys[assoc.foreign_key.to_sym]
|
141
141
|
hawk_definition = @hawk_keys[assoc.foreign_key.to_sym]
|
142
|
-
|
143
|
-
hawk_scope = hawk_definition[1]
|
144
|
-
hawked_association = "#{hawk_root}.#{hawk_scope}"
|
142
|
+
hawked_association = hawk_definition.join(".")
|
145
143
|
else
|
146
144
|
hawked_association = "#{assoc.class_name}.all"
|
147
145
|
end
|
@@ -225,7 +225,7 @@ module HotGlue
|
|
225
225
|
@singular = @singular.split("/").last
|
226
226
|
end
|
227
227
|
|
228
|
-
@plural = options['plural'] || @singular
|
228
|
+
@plural = options['plural'] || @singular.pluralize # respects what you set in inflections.rb, to override, use plural option
|
229
229
|
@namespace = options['namespace'] || nil
|
230
230
|
|
231
231
|
|
@@ -235,9 +235,9 @@ module HotGlue
|
|
235
235
|
@controller_build_folder = use_controller_name.underscore
|
236
236
|
@controller_build_folder_singular = singular
|
237
237
|
|
238
|
-
if ! @controller_build_folder.ends_with?("s")
|
239
|
-
|
240
|
-
end
|
238
|
+
# if ! @controller_build_folder.ends_with?("s")
|
239
|
+
# raise HotGlue::Error, "can't build with controller name #{@controller_build_folder} because it doesn't end with an 's'"
|
240
|
+
# end
|
241
241
|
|
242
242
|
@auth = options['auth'] || "current_user"
|
243
243
|
@auth_identifier = options['auth_identifier'] || (! @god && @auth.gsub("current_", "")) || nil
|
@@ -440,8 +440,12 @@ module HotGlue
|
|
440
440
|
key = hawk_entry
|
441
441
|
hawk_to = @auth
|
442
442
|
end
|
443
|
+
|
443
444
|
hawk_scope = key.gsub("_id", "").pluralize
|
444
|
-
@hawk_keys[key.to_sym] = [hawk_to
|
445
|
+
@hawk_keys[key.to_sym] = [hawk_to]
|
446
|
+
if @use_shorthand # only include the hawk scope if using the shorthand
|
447
|
+
@hawk_keys[key.to_sym] << hawk_scope
|
448
|
+
end
|
445
449
|
end
|
446
450
|
|
447
451
|
puts "HAWKING: #{@hawk_keys}"
|
data/lib/hotglue/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hot-glue
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Fleetwood-Boldt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|