hanami-controller 1.0.0.beta2 → 1.0.0.beta3
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/LICENSE.md +1 -1
- data/README.md +5 -5
- data/lib/hanami/action/base_params.rb +3 -0
- data/lib/hanami/action/cache.rb +1 -6
- data/lib/hanami/action/cache/cache_control.rb +12 -4
- data/lib/hanami/action/cache/conditional_get.rb +22 -1
- data/lib/hanami/action/cache/directives.rb +26 -1
- data/lib/hanami/action/cache/expires.rb +14 -4
- data/lib/hanami/action/callbacks.rb +4 -0
- data/lib/hanami/action/configurable.rb +1 -0
- data/lib/hanami/action/cookies.rb +0 -1
- data/lib/hanami/action/exposable/guard.rb +2 -0
- data/lib/hanami/action/head.rb +0 -1
- data/lib/hanami/action/mime.rb +1 -1
- data/lib/hanami/action/params.rb +30 -0
- data/lib/hanami/action/rack.rb +3 -0
- data/lib/hanami/action/rack/callable.rb +1 -1
- data/lib/hanami/action/request.rb +0 -1
- data/lib/hanami/action/session.rb +0 -1
- data/lib/hanami/action/throwable.rb +2 -0
- data/lib/hanami/action/validatable.rb +9 -6
- data/lib/hanami/controller.rb +6 -2
- data/lib/hanami/controller/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 051cedd7011bacf9ca4f4fd4b98d8b61c618ef63
|
4
|
+
data.tar.gz: bfbc96dddca32aab07238ba15068fedae3abddae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45d30eefef1706ddb0db5ff78083c778e6ae8eff2f34c3a434ec2df94883898a4ad5a9c9d6b5747664b9d17d4f872d0bf7b18c1dbce77bc1fce3f3e810c19d45
|
7
|
+
data.tar.gz: 9303820f4bd07c513945ec6008a52b2abf03b12b4b785853de7cc2aed436e91f08aa6ee08bf611f465d8351890e8f053d16b28be05afb697b3c7976fb5202da4
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
# Hanami::Controller
|
2
2
|
Complete, fast and testable actions for Rack
|
3
3
|
|
4
|
+
## v1.0.0.beta3 - 2017-03-17
|
5
|
+
### Changed
|
6
|
+
- [Luca Guidi] `Action#flash` is now public API
|
7
|
+
|
4
8
|
## v1.0.0.beta2 - 2017-03-02
|
5
9
|
### Added
|
6
10
|
- [Marcello Rocha] Add `Action#unsafe_send_file` to send files outside of the public directory of a project
|
data/LICENSE.md
CHANGED
data/README.md
CHANGED
@@ -202,8 +202,8 @@ class Signup
|
|
202
202
|
params do
|
203
203
|
required(:first_name).filled(:str?)
|
204
204
|
required(:last_name).filled(:str?)
|
205
|
-
required(:email).
|
206
|
-
required(:password).
|
205
|
+
required(:email).filled?(:str?, format?: /\A.+@.+\z/)
|
206
|
+
required(:password).filled(:str?).confirmation
|
207
207
|
required(:terms_of_service).filled(:bool?)
|
208
208
|
required(:age).filled(:int?, included_in?: 18..99)
|
209
209
|
optional(:avatar).filled(size?: 1..(MEGABYTE * 3))
|
@@ -940,7 +940,7 @@ class Csv
|
|
940
940
|
self.format = :csv
|
941
941
|
self.body = Enumerator.new do |yielder|
|
942
942
|
yielder << csv_header
|
943
|
-
|
943
|
+
|
944
944
|
# Expensive operation is streamed as each line becomes available
|
945
945
|
csv_body.each_line do |line|
|
946
946
|
yielder << line
|
@@ -950,7 +950,7 @@ class Csv
|
|
950
950
|
end
|
951
951
|
```
|
952
952
|
|
953
|
-
Note:
|
953
|
+
Note:
|
954
954
|
* In development, Hanami' code reloading needs to be disabled for streaming to work. This is because `Shotgun` interferes with the streaming action. You can disable it like this `hanami server --code-reloading=false`
|
955
955
|
* Streaming does not work with WEBrick as it buffers its response. We recommend using `puma`, though you may find success with other servers
|
956
956
|
|
@@ -1204,6 +1204,6 @@ __Hanami::Controller__ uses [Semantic Versioning 2.0.0](http://semver.org)
|
|
1204
1204
|
|
1205
1205
|
## Copyright
|
1206
1206
|
|
1207
|
-
Copyright © 2014-
|
1207
|
+
Copyright © 2014-2017 Luca Guidi – Released under MIT License
|
1208
1208
|
|
1209
1209
|
This project was formerly known as Lotus (`lotus-controller`).
|
@@ -7,12 +7,14 @@ module Hanami
|
|
7
7
|
# The key that returns raw input from the Rack env
|
8
8
|
#
|
9
9
|
# @since 0.7.0
|
10
|
+
# @api private
|
10
11
|
RACK_INPUT = 'rack.input'.freeze
|
11
12
|
|
12
13
|
# The key that returns router params from the Rack env
|
13
14
|
# This is a builtin integration for Hanami::Router
|
14
15
|
#
|
15
16
|
# @since 0.7.0
|
17
|
+
# @api private
|
16
18
|
ROUTER_PARAMS = 'router.params'.freeze
|
17
19
|
|
18
20
|
# The key that returns Rack session params from the Rack env
|
@@ -46,6 +48,7 @@ module Hanami
|
|
46
48
|
# @return [Params]
|
47
49
|
#
|
48
50
|
# @since 0.7.0
|
51
|
+
# @api private
|
49
52
|
def initialize(env)
|
50
53
|
@env = env
|
51
54
|
@raw = _extract_params
|
data/lib/hanami/action/cache.rb
CHANGED
@@ -20,7 +20,7 @@ module Hanami
|
|
20
20
|
# @since 0.3.0
|
21
21
|
# @api private
|
22
22
|
#
|
23
|
-
# @see http://www.ruby-doc.org/core
|
23
|
+
# @see http://www.ruby-doc.org/core/Module.html#method-i-included
|
24
24
|
def self.included(base)
|
25
25
|
base.class_eval do
|
26
26
|
include CacheControl, Expires
|
@@ -51,7 +51,6 @@ module Hanami
|
|
51
51
|
# @return void
|
52
52
|
#
|
53
53
|
# @since 0.3.0
|
54
|
-
# @api public
|
55
54
|
#
|
56
55
|
# @example
|
57
56
|
# require 'hanami/controller'
|
@@ -74,7 +73,6 @@ module Hanami
|
|
74
73
|
#
|
75
74
|
# end
|
76
75
|
# end
|
77
|
-
#
|
78
76
|
def cache_control(*values)
|
79
77
|
cache_control = CacheControl::Directives.new(*values)
|
80
78
|
headers.merge!(cache_control.headers)
|
@@ -91,7 +89,6 @@ module Hanami
|
|
91
89
|
# @return void
|
92
90
|
#
|
93
91
|
# @since 0.3.0
|
94
|
-
# @api public
|
95
92
|
#
|
96
93
|
# @example
|
97
94
|
# require 'hanami/controller'
|
@@ -115,7 +112,6 @@ module Hanami
|
|
115
112
|
#
|
116
113
|
# end
|
117
114
|
# end
|
118
|
-
#
|
119
115
|
def expires(amount, *values)
|
120
116
|
expires = Expires::Directives.new(amount, *values)
|
121
117
|
headers.merge!(expires.headers)
|
@@ -132,7 +128,6 @@ module Hanami
|
|
132
128
|
# @return void
|
133
129
|
#
|
134
130
|
# @since 0.3.0
|
135
|
-
# @api public
|
136
131
|
#
|
137
132
|
# @example
|
138
133
|
# require 'hanami/controller'
|
@@ -3,19 +3,19 @@ require 'hanami/action/cache/directives'
|
|
3
3
|
module Hanami
|
4
4
|
module Action
|
5
5
|
module Cache
|
6
|
-
|
7
6
|
# Module with Cache-Control logic
|
8
7
|
#
|
9
8
|
# @since 0.3.0
|
10
9
|
# @api private
|
11
10
|
module CacheControl
|
12
|
-
|
13
11
|
# The HTTP header for Cache-Control
|
14
12
|
#
|
15
13
|
# @since 0.3.0
|
16
14
|
# @api private
|
17
15
|
HEADER = 'Cache-Control'.freeze
|
18
16
|
|
17
|
+
# @since 0.3.0
|
18
|
+
# @api private
|
19
19
|
def self.included(base)
|
20
20
|
base.class_eval do
|
21
21
|
extend ClassMethods
|
@@ -23,11 +23,17 @@ module Hanami
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
+
# @since 0.3.0
|
27
|
+
# @api private
|
26
28
|
module ClassMethods
|
29
|
+
# @since 0.3.0
|
30
|
+
# @api private
|
27
31
|
def cache_control(*values)
|
28
32
|
@cache_control_directives ||= Directives.new(*values)
|
29
33
|
end
|
30
34
|
|
35
|
+
# @since 0.3.0
|
36
|
+
# @api private
|
31
37
|
def cache_control_directives
|
32
38
|
@cache_control_directives || Object.new.tap do |null_object|
|
33
39
|
def null_object.headers
|
@@ -51,14 +57,16 @@ module Hanami
|
|
51
57
|
# Class which stores CacheControl values
|
52
58
|
#
|
53
59
|
# @since 0.3.0
|
54
|
-
#
|
55
60
|
# @api private
|
56
|
-
#
|
57
61
|
class Directives
|
62
|
+
# @since 0.3.0
|
63
|
+
# @api private
|
58
64
|
def initialize(*values)
|
59
65
|
@directives = Hanami::Action::Cache::Directives.new(*values)
|
60
66
|
end
|
61
67
|
|
68
|
+
# @since 0.3.0
|
69
|
+
# @api private
|
62
70
|
def headers
|
63
71
|
if @directives.any?
|
64
72
|
{ HEADER => @directives.join(', ') }
|
@@ -25,22 +25,29 @@ module Hanami
|
|
25
25
|
#
|
26
26
|
# @since 0.3.0
|
27
27
|
# @api private
|
28
|
-
#
|
29
28
|
class ETag
|
29
|
+
# @since 0.3.0
|
30
|
+
# @api private
|
30
31
|
def initialize(env, value)
|
31
32
|
@env, @value = env, value
|
32
33
|
end
|
33
34
|
|
35
|
+
# @since 0.3.0
|
36
|
+
# @api private
|
34
37
|
def fresh?
|
35
38
|
none_match && @value == none_match
|
36
39
|
end
|
37
40
|
|
41
|
+
# @since 0.3.0
|
42
|
+
# @api private
|
38
43
|
def header
|
39
44
|
{ ETAG => @value } if none_match
|
40
45
|
end
|
41
46
|
|
42
47
|
private
|
43
48
|
|
49
|
+
# @since 0.3.0
|
50
|
+
# @api private
|
44
51
|
def none_match
|
45
52
|
@env[IF_NONE_MATCH]
|
46
53
|
end
|
@@ -51,20 +58,28 @@ module Hanami
|
|
51
58
|
# @since 0.3.0
|
52
59
|
# @api private
|
53
60
|
class LastModified
|
61
|
+
# @since 0.3.0
|
62
|
+
# @api private
|
54
63
|
def initialize(env, value)
|
55
64
|
@env, @value = env, value
|
56
65
|
end
|
57
66
|
|
67
|
+
# @since 0.3.0
|
68
|
+
# @api private
|
58
69
|
def fresh?
|
59
70
|
!Hanami::Utils::Blank.blank?(modified_since) && Time.httpdate(modified_since).to_i >= @value.to_i
|
60
71
|
end
|
61
72
|
|
73
|
+
# @since 0.3.0
|
74
|
+
# @api private
|
62
75
|
def header
|
63
76
|
{ LAST_MODIFIED => @value.httpdate } if modified_since
|
64
77
|
end
|
65
78
|
|
66
79
|
private
|
67
80
|
|
81
|
+
# @since 0.3.0
|
82
|
+
# @api private
|
68
83
|
def modified_since
|
69
84
|
@env[IF_MODIFIED_SINCE]
|
70
85
|
end
|
@@ -76,14 +91,20 @@ module Hanami
|
|
76
91
|
# @since 0.3.0
|
77
92
|
# @api private
|
78
93
|
class ConditionalGet
|
94
|
+
# @since 0.3.0
|
95
|
+
# @api private
|
79
96
|
def initialize(env, options)
|
80
97
|
@validations = [ ETag.new(env, options[:etag]), LastModified.new(env, options[:last_modified]) ]
|
81
98
|
end
|
82
99
|
|
100
|
+
# @since 0.3.0
|
101
|
+
# @api private
|
83
102
|
def fresh?
|
84
103
|
yield if @validations.any?(&:fresh?)
|
85
104
|
end
|
86
105
|
|
106
|
+
# @since 0.3.0
|
107
|
+
# @api private
|
87
108
|
def headers
|
88
109
|
@validations.map(&:header).compact.reduce Hash.new, :merge
|
89
110
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
module Hanami
|
2
2
|
module Action
|
3
3
|
module Cache
|
4
|
-
|
5
4
|
# Cache-Control directives which have values
|
6
5
|
#
|
7
6
|
# @since 0.3.0
|
@@ -21,16 +20,24 @@ module Hanami
|
|
21
20
|
# @since 0.3.0
|
22
21
|
# @api private
|
23
22
|
class ValueDirective
|
23
|
+
# @since 0.3.0
|
24
|
+
# @api private
|
24
25
|
attr_reader :name
|
25
26
|
|
27
|
+
# @since 0.3.0
|
28
|
+
# @api private
|
26
29
|
def initialize(name, value)
|
27
30
|
@name, @value = name, value
|
28
31
|
end
|
29
32
|
|
33
|
+
# @since 0.3.0
|
34
|
+
# @api private
|
30
35
|
def to_str
|
31
36
|
"#{@name.to_s.tr('_', '-')}=#{@value.to_i}"
|
32
37
|
end
|
33
38
|
|
39
|
+
# @since 0.3.0
|
40
|
+
# @api private
|
34
41
|
def valid?
|
35
42
|
VALUE_DIRECTIVES.include? @name
|
36
43
|
end
|
@@ -43,16 +50,24 @@ module Hanami
|
|
43
50
|
# @since 0.3.0
|
44
51
|
# @api private
|
45
52
|
class NonValueDirective
|
53
|
+
# @since 0.3.0
|
54
|
+
# @api private
|
46
55
|
attr_reader :name
|
47
56
|
|
57
|
+
# @since 0.3.0
|
58
|
+
# @api private
|
48
59
|
def initialize(name)
|
49
60
|
@name = name
|
50
61
|
end
|
51
62
|
|
63
|
+
# @since 0.3.0
|
64
|
+
# @api private
|
52
65
|
def to_str
|
53
66
|
@name.to_s.tr('_', '-')
|
54
67
|
end
|
55
68
|
|
69
|
+
# @since 0.3.0
|
70
|
+
# @api private
|
56
71
|
def valid?
|
57
72
|
NON_VALUE_DIRECTIVES.include? @name
|
58
73
|
end
|
@@ -65,6 +80,8 @@ module Hanami
|
|
65
80
|
class Directives
|
66
81
|
include Enumerable
|
67
82
|
|
83
|
+
# @since 0.3.0
|
84
|
+
# @api private
|
68
85
|
def initialize(*values)
|
69
86
|
@directives = []
|
70
87
|
values.each do |directive_key|
|
@@ -76,20 +93,28 @@ module Hanami
|
|
76
93
|
end
|
77
94
|
end
|
78
95
|
|
96
|
+
# @since 0.3.0
|
97
|
+
# @api private
|
79
98
|
def each
|
80
99
|
@directives.each { |d| yield d }
|
81
100
|
end
|
82
101
|
|
102
|
+
# @since 0.3.0
|
103
|
+
# @api private
|
83
104
|
def <<(directive)
|
84
105
|
@directives << directive if directive.valid?
|
85
106
|
end
|
86
107
|
|
108
|
+
# @since 0.3.0
|
109
|
+
# @api private
|
87
110
|
def values
|
88
111
|
@directives.delete_if do |directive|
|
89
112
|
directive.name == :public && @directives.map(&:name).include?(:private)
|
90
113
|
end
|
91
114
|
end
|
92
115
|
|
116
|
+
# @since 0.3.0
|
117
|
+
# @api private
|
93
118
|
def join(separator)
|
94
119
|
values.join(separator)
|
95
120
|
end
|
@@ -3,19 +3,19 @@ require 'hanami/action/cache/cache_control'
|
|
3
3
|
module Hanami
|
4
4
|
module Action
|
5
5
|
module Cache
|
6
|
-
|
7
6
|
# Module with Expires logic
|
8
7
|
#
|
9
8
|
# @since 0.3.0
|
10
9
|
# @api private
|
11
10
|
module Expires
|
12
|
-
|
13
11
|
# The HTTP header for Expires
|
14
12
|
#
|
15
13
|
# @since 0.3.0
|
16
14
|
# @api private
|
17
15
|
HEADER = 'Expires'.freeze
|
18
16
|
|
17
|
+
# @since 0.3.0
|
18
|
+
# @api private
|
19
19
|
def self.included(base)
|
20
20
|
base.class_eval do
|
21
21
|
extend ClassMethods
|
@@ -23,11 +23,17 @@ module Hanami
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
+
# @since 0.3.0
|
27
|
+
# @api private
|
26
28
|
module ClassMethods
|
29
|
+
# @since 0.3.0
|
30
|
+
# @api private
|
27
31
|
def expires(amount, *values)
|
28
32
|
@expires_directives ||= Directives.new(amount, *values)
|
29
33
|
end
|
30
34
|
|
35
|
+
# @since 0.3.0
|
36
|
+
# @api private
|
31
37
|
def expires_directives
|
32
38
|
@expires_directives || Object.new.tap do |null_object|
|
33
39
|
def null_object.headers
|
@@ -51,21 +57,25 @@ module Hanami
|
|
51
57
|
# Class which stores Expires directives
|
52
58
|
#
|
53
59
|
# @since 0.3.0
|
54
|
-
#
|
55
60
|
# @api private
|
56
|
-
#
|
57
61
|
class Directives
|
62
|
+
# @since 0.3.0
|
63
|
+
# @api private
|
58
64
|
def initialize(amount, *values)
|
59
65
|
@amount = amount
|
60
66
|
@cache_control = Hanami::Action::Cache::CacheControl::Directives.new(*(values << { max_age: amount }))
|
61
67
|
end
|
62
68
|
|
69
|
+
# @since 0.3.0
|
70
|
+
# @api private
|
63
71
|
def headers
|
64
72
|
{ HEADER => time.httpdate }.merge(@cache_control.headers)
|
65
73
|
end
|
66
74
|
|
67
75
|
private
|
68
76
|
|
77
|
+
# @since 0.3.0
|
78
|
+
# @api private
|
69
79
|
def time
|
70
80
|
Time.now + @amount.to_i
|
71
81
|
end
|
@@ -197,10 +197,14 @@ module Hanami
|
|
197
197
|
end
|
198
198
|
|
199
199
|
private
|
200
|
+
# @since 0.1.0
|
201
|
+
# @api private
|
200
202
|
def _run_before_callbacks(params)
|
201
203
|
self.class.before_callbacks.run(self, params)
|
202
204
|
end
|
203
205
|
|
206
|
+
# @since 0.1.0
|
207
|
+
# @api private
|
204
208
|
def _run_after_callbacks(params)
|
205
209
|
self.class.after_callbacks.run(self, params)
|
206
210
|
end
|
@@ -15,6 +15,7 @@ module Hanami
|
|
15
15
|
# Prevents exposure of reserved words
|
16
16
|
#
|
17
17
|
# @since 0.7.1
|
18
|
+
# @api private
|
18
19
|
#
|
19
20
|
# @see Hanami::Action::Exposable::Guard::ClassMethods#expose
|
20
21
|
# @see Hanami::Action::Exposable::Guard::ClassMethods#reserved_word?
|
@@ -47,6 +48,7 @@ module Hanami
|
|
47
48
|
# @return [void]
|
48
49
|
#
|
49
50
|
# @since 0.7.1
|
51
|
+
# @api private
|
50
52
|
def expose(*names)
|
51
53
|
detect_reserved_words!(names)
|
52
54
|
|
data/lib/hanami/action/head.rb
CHANGED
data/lib/hanami/action/mime.rb
CHANGED
data/lib/hanami/action/params.rb
CHANGED
@@ -26,6 +26,34 @@ module Hanami
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
+
# Define params validations
|
30
|
+
#
|
31
|
+
# @param blk [Proc] the validations definitions
|
32
|
+
#
|
33
|
+
# @since 0.7.0
|
34
|
+
#
|
35
|
+
# @see http://hanamirb.org/guides/validations/overview/
|
36
|
+
#
|
37
|
+
# @example
|
38
|
+
# class Signup
|
39
|
+
# MEGABYTE = 1024 ** 2
|
40
|
+
# include Hanami::Action
|
41
|
+
#
|
42
|
+
# params do
|
43
|
+
# required(:first_name).filled(:str?)
|
44
|
+
# required(:last_name).filled(:str?)
|
45
|
+
# required(:email).filled?(:str?, format?: /\A.+@.+\z/)
|
46
|
+
# required(:password).filled(:str?).confirmation
|
47
|
+
# required(:terms_of_service).filled(:bool?)
|
48
|
+
# required(:age).filled(:int?, included_in?: 18..99)
|
49
|
+
# optional(:avatar).filled(size?: 1..(MEGABYTE * 3))
|
50
|
+
# end
|
51
|
+
#
|
52
|
+
# def call(params)
|
53
|
+
# halt 400 unless params.valid?
|
54
|
+
# # ...
|
55
|
+
# end
|
56
|
+
# end
|
29
57
|
def self.params(&blk)
|
30
58
|
validations(&blk || ->() {})
|
31
59
|
end
|
@@ -37,6 +65,7 @@ module Hanami
|
|
37
65
|
# @return [Params]
|
38
66
|
#
|
39
67
|
# @since 0.1.0
|
68
|
+
# @api private
|
40
69
|
def initialize(env)
|
41
70
|
@env = env
|
42
71
|
super(_extract_params)
|
@@ -115,6 +144,7 @@ module Hanami
|
|
115
144
|
|
116
145
|
private
|
117
146
|
|
147
|
+
# @api private
|
118
148
|
def _params
|
119
149
|
@result.output.merge(_router_params)
|
120
150
|
end
|
data/lib/hanami/action/rack.rb
CHANGED
@@ -98,10 +98,12 @@ module Hanami
|
|
98
98
|
end
|
99
99
|
end
|
100
100
|
|
101
|
+
# @api private
|
101
102
|
module ClassMethods
|
102
103
|
# Build rack builder
|
103
104
|
#
|
104
105
|
# @return [Rack::Builder]
|
106
|
+
# @api private
|
105
107
|
def rack_builder
|
106
108
|
@rack_builder ||= begin
|
107
109
|
extend Hanami::Action::Rack::Callable
|
@@ -242,6 +244,7 @@ module Hanami
|
|
242
244
|
@request ||= ::Hanami::Action::Request.new(@_env)
|
243
245
|
end
|
244
246
|
|
247
|
+
# Return parsed request body
|
245
248
|
def parsed_request_body
|
246
249
|
@_env.fetch(ROUTER_PARSED_BODY, nil)
|
247
250
|
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
module Hanami
|
3
2
|
module Action
|
4
3
|
module Rack
|
@@ -10,6 +9,7 @@ module Hanami
|
|
10
9
|
# see the examples below.
|
11
10
|
#
|
12
11
|
# @since 0.4.0
|
12
|
+
# @api private
|
13
13
|
#
|
14
14
|
# @see Hanami::Action::Rack::ClassMethods#rack_builder
|
15
15
|
# @see Hanami::Action::Rack::ClassMethods#use
|
@@ -9,6 +9,8 @@ module Hanami
|
|
9
9
|
# @since 0.3.0
|
10
10
|
PARAMS_CLASS_NAME = 'Params'.freeze
|
11
11
|
|
12
|
+
# @api private
|
13
|
+
# @since 0.1.0
|
12
14
|
def self.included(base)
|
13
15
|
base.extend ClassMethods
|
14
16
|
end
|
@@ -48,6 +50,7 @@ module Hanami
|
|
48
50
|
# @since 0.3.0
|
49
51
|
#
|
50
52
|
# @see Hanami::Action::Params
|
53
|
+
# @see http://hanamirb.org/guides/validations/overview/
|
51
54
|
#
|
52
55
|
# @example Anonymous Block
|
53
56
|
# require 'hanami/controller'
|
@@ -56,9 +59,9 @@ module Hanami
|
|
56
59
|
# include Hanami::Action
|
57
60
|
#
|
58
61
|
# params do
|
59
|
-
#
|
60
|
-
#
|
61
|
-
#
|
62
|
+
# required(:first_name)
|
63
|
+
# required(:last_name)
|
64
|
+
# required(:email)
|
62
65
|
# end
|
63
66
|
#
|
64
67
|
# def call(params)
|
@@ -74,9 +77,9 @@ module Hanami
|
|
74
77
|
# require 'hanami/controller'
|
75
78
|
#
|
76
79
|
# class SignupParams < Hanami::Action::Params
|
77
|
-
#
|
78
|
-
#
|
79
|
-
#
|
80
|
+
# required(:first_name)
|
81
|
+
# required(:last_name)
|
82
|
+
# required(:email)
|
80
83
|
# end
|
81
84
|
#
|
82
85
|
# class Signup
|
data/lib/hanami/controller.rb
CHANGED
@@ -4,6 +4,9 @@ require 'hanami/controller/configuration'
|
|
4
4
|
require 'hanami/controller/version'
|
5
5
|
require 'hanami/controller/error'
|
6
6
|
|
7
|
+
# Hanami
|
8
|
+
#
|
9
|
+
# @since 0.1.0
|
7
10
|
module Hanami
|
8
11
|
# A set of logically grouped actions
|
9
12
|
#
|
@@ -37,6 +40,8 @@ module Hanami
|
|
37
40
|
#
|
38
41
|
# @see Hanami::Action::Mime#format=
|
39
42
|
class UnknownFormatError < Hanami::Controller::Error
|
43
|
+
# @since 0.2.0
|
44
|
+
# @api private
|
40
45
|
def initialize(format)
|
41
46
|
super("Cannot find a corresponding Mime type for '#{ format }'. Please configure it with Hanami::Controller::Configuration#format.")
|
42
47
|
end
|
@@ -130,7 +135,7 @@ module Hanami
|
|
130
135
|
#
|
131
136
|
# @return [Module] a copy of Hanami::Controller
|
132
137
|
#
|
133
|
-
#
|
138
|
+
# @since 0.2.0
|
134
139
|
#
|
135
140
|
# @see Hanami::Controller#dupe
|
136
141
|
# @see Hanami::Controller::Configuration
|
@@ -252,4 +257,3 @@ module Hanami
|
|
252
257
|
end
|
253
258
|
end
|
254
259
|
end
|
255
|
-
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hanami-controller
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.beta3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luca Guidi
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2017-03-
|
13
|
+
date: 2017-03-17 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rack
|