hanami-view 2.0.0.alpha3 → 2.0.0.alpha5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/hanami/view/application_context.rb +40 -18
- data/lib/hanami/view/context.rb +3 -2
- data/lib/hanami/view/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec11d28fb1ab17f2de3bfa384fce768648a6975f6f5261795b239069733a5df2
|
4
|
+
data.tar.gz: 6f631fa7bdd6528d406534f074ec7df1823e46a4ae692a0c4b83e6c8ba30efbf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ca038a05ffb5361ca9e61820af0487498f3a6dee0842f33f5f51577127e36fd6f97eea13df0984a64cb66d093a0c331a943736856589062310f1b0c2d40eada
|
7
|
+
data.tar.gz: 3468190981d001cbb87618779abae17ce19700cb7855ac70db09db5895f23cea4056ea580aa967b7a59f1168d6801fc93129184aa4afcfb871682e1386feb0ed
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
# Hanami::View
|
2
2
|
View layer for Hanami
|
3
3
|
|
4
|
+
## v2.0.0.alpha5 - 2022-01-12
|
5
|
+
### Added
|
6
|
+
- [Marc Busqué] Automatically provide access to Hanami application routes helper as `routes` in default application view context (`Hanami::View::ApplicationContext`)
|
7
|
+
|
4
8
|
## v2.0.0.alpha3 - 2021-11-09
|
5
9
|
### Added
|
6
10
|
- [Pablo Vicente] Raise `LayoutNotFoundError` exception with friendlier, more specific error message when layouts cannot be found
|
@@ -2,33 +2,55 @@
|
|
2
2
|
|
3
3
|
module Hanami
|
4
4
|
class View
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
super
|
9
|
-
end
|
5
|
+
class ApplicationContext < Module
|
6
|
+
attr_reader :provider
|
7
|
+
attr_reader :application
|
10
8
|
|
11
|
-
def
|
12
|
-
@
|
9
|
+
def initialize(provider)
|
10
|
+
@provider = provider
|
11
|
+
@application = provider.respond_to?(:application) ? provider.application : Hanami.application
|
13
12
|
end
|
14
13
|
|
15
|
-
def
|
16
|
-
|
14
|
+
def included(context_class)
|
15
|
+
define_initialize
|
16
|
+
context_class.include(InstanceMethods)
|
17
17
|
end
|
18
18
|
|
19
|
-
|
20
|
-
request.session
|
21
|
-
end
|
19
|
+
private
|
22
20
|
|
23
|
-
def
|
24
|
-
|
21
|
+
def define_initialize
|
22
|
+
inflector = application.inflector
|
23
|
+
routes = application[:routes_helper] if application.key?(:routes_helper)
|
24
|
+
|
25
|
+
define_method :initialize do |**options|
|
26
|
+
@inflector = options[:inflector] || inflector
|
27
|
+
@routes = options[:routes] || routes
|
28
|
+
super(**options)
|
29
|
+
end
|
25
30
|
end
|
26
31
|
|
27
|
-
|
32
|
+
module InstanceMethods
|
33
|
+
attr_reader :inflector
|
34
|
+
attr_reader :routes
|
35
|
+
|
36
|
+
def request
|
37
|
+
_options.fetch(:request)
|
38
|
+
end
|
39
|
+
|
40
|
+
def session
|
41
|
+
request.session
|
42
|
+
end
|
43
|
+
|
44
|
+
def flash
|
45
|
+
response.flash
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
28
49
|
|
29
|
-
|
30
|
-
|
31
|
-
|
50
|
+
# TODO: create `Request#flash` so we no longer need the `response`
|
51
|
+
def response
|
52
|
+
_options.fetch(:response)
|
53
|
+
end
|
32
54
|
end
|
33
55
|
end
|
34
56
|
end
|
data/lib/hanami/view/context.rb
CHANGED
@@ -23,8 +23,9 @@ module Hanami
|
|
23
23
|
super
|
24
24
|
|
25
25
|
# When inheriting within an Hanami app, add application context behavior
|
26
|
-
|
27
|
-
|
26
|
+
provider = application_provider(subclass)
|
27
|
+
if provider
|
28
|
+
subclass.include ApplicationContext.new(provider)
|
28
29
|
end
|
29
30
|
end
|
30
31
|
|
data/lib/hanami/view/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hanami-view
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0.
|
4
|
+
version: 2.0.0.alpha5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Riley
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2022-01-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: concurrent-ruby
|