yiffspace-core 0.2.0 → 0.2.1
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/CHANGELOG.md +12 -0
- data/lib/yiffspace/core/version.rb +1 -1
- data/lib/yiffspace/utils/helpers.rb +28 -4
- data/lib/yiffspace/utils/routes.rb +2 -2
- 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: d9e70befbca65b0155e1a317149268f3c4b88812312e6c382c331d306b04816e
|
|
4
|
+
data.tar.gz: 2bf60d4c568ac65d5dc97a6699b6f5d4e94a9066d9d4d7f3bd5808a3481b03d6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 86cc77b00d1b2308afddd100d3cc20ad8194669bb0e030ea2e44763e798c703560b321a58162b4acd09d5502777fde4283f57e981d5dcc7662dd5932037c8a77
|
|
7
|
+
data.tar.gz: a77cb9429d123a90b4d290934a453d55790c2978c50a03cdacb4804eb70dddfb6afd05ba9e38cb404b250f0b848e03dda36190044b81af697e5c6a28017906b6
|
data/CHANGELOG.md
CHANGED
|
@@ -32,6 +32,18 @@
|
|
|
32
32
|
- The dummy test app no longer needs Postgres - only the fixes table's
|
|
33
33
|
`nulls_not_distinct` index required it, and that lives in `yiffspace-fixers`
|
|
34
34
|
now. Back to plain sqlite3, `docker-compose.yml` removed.
|
|
35
|
+
- Fixed `YiffSpace::Utils::Helpers`/`Routes` (`Helpers`/`Routes` under
|
|
36
|
+
`yiffspace-include`) dropping keyword arguments: their `method_missing` used
|
|
37
|
+
a bare `*, &` splat, which isn't `ruby2_keywords`-aware, so a call like
|
|
38
|
+
`h.some_helper(post, tags: tags)` arrived with the `tags:` hash flattened
|
|
39
|
+
into a positional argument instead of a keyword - silently landing in
|
|
40
|
+
whatever parameter came next rather than raising. Both now use `...` to
|
|
41
|
+
forward positional, keyword, and block arguments correctly.
|
|
42
|
+
- `YiffSpace::Utils::Helpers` (`Helpers`) now also makes the app's route
|
|
43
|
+
`_path`/`_url` helpers available *inside* the helper methods it proxies to,
|
|
44
|
+
not just to callers going through it directly - a helper that itself calls
|
|
45
|
+
`some_path(...)` (with no receiver) now works the same way it would from a
|
|
46
|
+
real view, instead of raising `NoMethodError`.
|
|
35
47
|
|
|
36
48
|
## 0.1.0
|
|
37
49
|
|
|
@@ -10,16 +10,40 @@ module YiffSpace
|
|
|
10
10
|
# `h.some_helper`), including ones marked private in their helper module - private only
|
|
11
11
|
# restricts calling with an explicit receiver, and normal view rendering (which invokes
|
|
12
12
|
# helpers without one) isn't affected either way.
|
|
13
|
-
def method_missing(name,
|
|
14
|
-
helpers =
|
|
15
|
-
return helpers.send(name,
|
|
13
|
+
def method_missing(name, ...)
|
|
14
|
+
helpers = target
|
|
15
|
+
return helpers.send(name, ...) if helpers.respond_to?(name, true)
|
|
16
16
|
|
|
17
17
|
super
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
def respond_to_missing?(name, include_private = false)
|
|
21
|
-
|
|
21
|
+
target.respond_to?(name, true) || super
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# ApplicationController.helpers behaves like a view for registered helper modules, but
|
|
25
|
+
# (unlike an actual view) doesn't include the app's route url_helpers - so a helper method
|
|
26
|
+
# invoked through this proxy couldn't call `some_path`/`some_url` itself. Extend the shared
|
|
27
|
+
# proxy once so route helpers are available from inside helper methods too, not just to
|
|
28
|
+
# callers going through this module directly.
|
|
29
|
+
#
|
|
30
|
+
# `extend`ing the generated url_helpers module only grants the path/url helper methods
|
|
31
|
+
# themselves - they're written to call `url_options`/`_routes`/`optimize_routes_generation?`
|
|
32
|
+
# on whatever they're called on, and the module only defines those three on its own
|
|
33
|
+
# singleton class (so it works standalone), not as instance methods `extend` would carry
|
|
34
|
+
# over. Delegate them by hand so the extended methods have what they need to run.
|
|
35
|
+
def target
|
|
36
|
+
helpers = YiffSpace.config.application_controller_class.helpers
|
|
37
|
+
url_helpers = Rails.application.routes.url_helpers
|
|
38
|
+
unless helpers.is_a?(url_helpers)
|
|
39
|
+
helpers.define_singleton_method(:url_options) { url_helpers.url_options }
|
|
40
|
+
helpers.define_singleton_method(:_routes) { url_helpers._routes }
|
|
41
|
+
helpers.define_singleton_method(:optimize_routes_generation?) { url_helpers.optimize_routes_generation? }
|
|
42
|
+
helpers.extend(url_helpers)
|
|
43
|
+
end
|
|
44
|
+
helpers
|
|
22
45
|
end
|
|
46
|
+
private_class_method(:target)
|
|
23
47
|
end
|
|
24
48
|
end
|
|
25
49
|
end
|
|
@@ -13,9 +13,9 @@ module YiffSpace
|
|
|
13
13
|
module Routes
|
|
14
14
|
module_function
|
|
15
15
|
|
|
16
|
-
def method_missing(name,
|
|
16
|
+
def method_missing(name, ...)
|
|
17
17
|
url_helpers = Rails.application.routes.url_helpers
|
|
18
|
-
return url_helpers.public_send(name,
|
|
18
|
+
return url_helpers.public_send(name, ...) if url_helpers.respond_to?(name)
|
|
19
19
|
|
|
20
20
|
super
|
|
21
21
|
end
|