redress 0.2.1 → 0.2.2
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/README.md +29 -6
- data/lib/redress/identity.rb +1 -1
- data/lib/redress/utils/parse_attributes_from_params.rb +9 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c939634da1dd6e77568b2d4fa2bcf533340b718
|
4
|
+
data.tar.gz: 369e02b67e16a7f25af5776f93325cdeed7d4c5f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8d60487e7cb69fdda743027008fe4b5eb22356de0db1bb033deb710f5382901aa8de9ab3361762f1d64e82bb15e764257448531c6932e93507c15cc2e1e58fe
|
7
|
+
data.tar.gz: d62e7d6b92ba0bcd4366c6a4f8e2752526341c6dfe1c398fc9ee59f9d38ba8918ef5db7e82c69ec92e21649dbbf80c474267ee9d45327874f811d5565b3270ba
|
data/README.md
CHANGED
@@ -49,7 +49,7 @@ Add the following to your Gemfile:
|
|
49
49
|
|
50
50
|
### Forms
|
51
51
|
|
52
|
-
```
|
52
|
+
```ruby
|
53
53
|
# app/forms/application_form.rb
|
54
54
|
require 'redress/form'
|
55
55
|
|
@@ -59,7 +59,7 @@ end
|
|
59
59
|
|
60
60
|
Let's define simple form:
|
61
61
|
|
62
|
-
```
|
62
|
+
```ruby
|
63
63
|
class SimpleForm < ApplicationForm
|
64
64
|
mimic :user
|
65
65
|
|
@@ -80,9 +80,32 @@ class SimpleForm < ApplicationForm
|
|
80
80
|
end
|
81
81
|
```
|
82
82
|
|
83
|
+
Form with multiple comments:
|
84
|
+
|
85
|
+
```ruby
|
86
|
+
class CommentForm < Redress::Form
|
87
|
+
define_schema do
|
88
|
+
attribute :id, Redress::Types::Form::Int
|
89
|
+
attribute :content, Redress::Types::String
|
90
|
+
end
|
91
|
+
|
92
|
+
validates :content, presence: true
|
93
|
+
end
|
94
|
+
|
95
|
+
class OrderForm < Redress::Form
|
96
|
+
mimic :order
|
97
|
+
|
98
|
+
define_schema do
|
99
|
+
attribute :title, Redress::Types::String
|
100
|
+
attribute :comments, Redress::Types::Array.member(CommentForm)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
```
|
104
|
+
|
105
|
+
|
83
106
|
### Commands
|
84
107
|
|
85
|
-
```
|
108
|
+
```ruby
|
86
109
|
# app/commands/application_command.rb
|
87
110
|
require 'redress/command'
|
88
111
|
|
@@ -92,7 +115,7 @@ end
|
|
92
115
|
|
93
116
|
Or if you are using ActiveRecord:
|
94
117
|
|
95
|
-
```
|
118
|
+
```ruby
|
96
119
|
# app/commands/application_command.rb
|
97
120
|
require 'redress/command'
|
98
121
|
|
@@ -105,7 +128,7 @@ end
|
|
105
128
|
|
106
129
|
Simple command for user registration:
|
107
130
|
|
108
|
-
```
|
131
|
+
```ruby
|
109
132
|
# app/commands/users/create_command.rb
|
110
133
|
module Users
|
111
134
|
class CreateCommand < ApplicationCommand
|
@@ -126,7 +149,7 @@ end
|
|
126
149
|
|
127
150
|
### Controllers
|
128
151
|
|
129
|
-
```
|
152
|
+
```ruby
|
130
153
|
# app/controllers/users_controller.rb
|
131
154
|
class UsersController < Account::BaseController
|
132
155
|
respond_to :json, only: :update
|
data/lib/redress/identity.rb
CHANGED
@@ -7,7 +7,7 @@ module Redress
|
|
7
7
|
class ParseAttributesFromParams
|
8
8
|
def initialize(klass, params, options = nil)
|
9
9
|
@klass = klass
|
10
|
-
@params = params
|
10
|
+
@params = convert_params_to_hash(params)
|
11
11
|
@options = (options || {})
|
12
12
|
end
|
13
13
|
|
@@ -53,6 +53,14 @@ module Redress
|
|
53
53
|
|
54
54
|
hash
|
55
55
|
end
|
56
|
+
|
57
|
+
def convert_params_to_hash(params)
|
58
|
+
if params.respond_to?(:to_unsafe_h)
|
59
|
+
params.to_unsafe_h
|
60
|
+
else
|
61
|
+
params
|
62
|
+
end
|
63
|
+
end
|
56
64
|
end
|
57
65
|
end
|
58
66
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redress
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Galeta
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-10-
|
11
|
+
date: 2017-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: wisper
|
@@ -192,6 +192,20 @@ dependencies:
|
|
192
192
|
- - "~>"
|
193
193
|
- !ruby/object:Gem::Version
|
194
194
|
version: 0.8.21
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: actionpack
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - "~>"
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: 5.1.4
|
202
|
+
type: :development
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - "~>"
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: 5.1.4
|
195
209
|
description:
|
196
210
|
email:
|
197
211
|
- galeta.igor@gmail.com
|