cyrax 0.5.11 → 0.5.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/cyrax/decorator.rb +2 -0
- data/lib/cyrax/extensions/has_service.rb +2 -2
- data/lib/cyrax/helpers/controller.rb +5 -2
- data/lib/cyrax/serializers/scope.rb +2 -1
- data/lib/cyrax/version.rb +1 -1
- data/lib/cyrax.rb +9 -0
- metadata +16 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ffa73afcc3fa3024643e425b5063022a1868c533b684db1b3051e0a5512ba02e
|
4
|
+
data.tar.gz: 51db666b13256c83848a69f9c62c5796749ff68113261870ad1552b6c73beabf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 926899dc59201b60ca43de71876abfbfca228b10a8622b89cde69fd5befc6cbd30f2583f6cbbe874c759f1304b96c44ffa0971cdc26f4753cec355a352d75abf
|
7
|
+
data.tar.gz: b42a00f20a319fdd645d539b069cc6849775014a77871c3465c23a4af6e76a959d553f0ef7ffd9602fbeb331419e041e5d0c668b2f22f7a2253865bb1b225c07
|
data/lib/cyrax/decorator.rb
CHANGED
@@ -36,7 +36,7 @@ module Cyrax::Extensions
|
|
36
36
|
if save_resource(resource)
|
37
37
|
set_message(:created)
|
38
38
|
block.call(resource) if block_given?
|
39
|
-
|
39
|
+
elsif Cyrax.automatically_set_invalid_status
|
40
40
|
set_status VALIDATION_ERROR_STATUS
|
41
41
|
end
|
42
42
|
end
|
@@ -66,7 +66,7 @@ module Cyrax::Extensions
|
|
66
66
|
if save_resource(resource)
|
67
67
|
set_message(:updated)
|
68
68
|
block.call(resource) if block_given?
|
69
|
-
|
69
|
+
elsif Cyrax.automatically_set_invalid_status
|
70
70
|
set_status VALIDATION_ERROR_STATUS
|
71
71
|
end
|
72
72
|
end
|
@@ -15,7 +15,7 @@ module Cyrax::ControllerHelper
|
|
15
15
|
result = result.to_model if result.respond_to?(:to_model)
|
16
16
|
|
17
17
|
respond_to do |format|
|
18
|
-
format.
|
18
|
+
format.html do
|
19
19
|
# set flashes
|
20
20
|
if response.success?
|
21
21
|
flash[:notice] = options[:notice] if options[:notice].present?
|
@@ -24,11 +24,14 @@ module Cyrax::ControllerHelper
|
|
24
24
|
flash.now[:error] = options[:error] if options[:error].present?
|
25
25
|
end
|
26
26
|
set_resource_from(response)
|
27
|
-
super(result, options, &block)
|
28
27
|
end
|
29
28
|
format.json do
|
30
29
|
render json: MultiJson.dump(response.as_json), status: options[:status] || 200
|
31
30
|
end
|
31
|
+
format.any do
|
32
|
+
set_resource_from(response)
|
33
|
+
super(response, options, &block)
|
34
|
+
end
|
32
35
|
end
|
33
36
|
else
|
34
37
|
super(*args)
|
@@ -69,7 +69,8 @@ module Cyrax::Serializers
|
|
69
69
|
result[attribute] = scope.serialize(value, options)
|
70
70
|
end
|
71
71
|
@assigned_attrs.map do |attribute, scope|
|
72
|
-
|
72
|
+
assignments = options[:assignments] || {}
|
73
|
+
value = assignments[attribute]
|
73
74
|
result[attribute] = scope.serialize(value, options)
|
74
75
|
end
|
75
76
|
@namespace_attrs.map do |attribute, scope|
|
data/lib/cyrax/version.rb
CHANGED
data/lib/cyrax.rb
CHANGED
@@ -20,6 +20,7 @@ require "cyrax/serializer.rb"
|
|
20
20
|
|
21
21
|
module Cyrax
|
22
22
|
@@strong_parameters = true
|
23
|
+
@@automatically_set_invalid_status = true
|
23
24
|
|
24
25
|
def self.strong_parameters
|
25
26
|
@@strong_parameters
|
@@ -28,4 +29,12 @@ module Cyrax
|
|
28
29
|
def self.strong_parameters=(value)
|
29
30
|
@@strong_parameters = value
|
30
31
|
end
|
32
|
+
|
33
|
+
def self.automatically_set_invalid_status
|
34
|
+
@@automatically_set_invalid_status
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.automatically_set_invalid_status=(value)
|
38
|
+
@@automatically_set_invalid_status = value
|
39
|
+
end
|
31
40
|
end
|
metadata
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cyrax
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Droidlabs
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-06-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '4.2'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '4.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activemodel
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '4.2'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '4.2'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: has_active_logger
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -150,19 +150,18 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
150
|
- !ruby/object:Gem::Version
|
151
151
|
version: '0'
|
152
152
|
requirements: []
|
153
|
-
|
154
|
-
rubygems_version: 2.2.2
|
153
|
+
rubygems_version: 3.0.3.1
|
155
154
|
signing_key:
|
156
155
|
specification_version: 4
|
157
156
|
summary: Small library for adding service layer to Rails projects
|
158
157
|
test_files:
|
159
|
-
- spec/cyrax/base_spec.rb
|
160
|
-
- spec/cyrax/decorator_spec.rb
|
161
|
-
- spec/cyrax/extensions/has_decorator_spec.rb
|
162
158
|
- spec/cyrax/extensions/has_resource_spec.rb
|
163
|
-
- spec/cyrax/extensions/has_response_spec.rb
|
164
159
|
- spec/cyrax/extensions/has_service_spec.rb
|
165
|
-
- spec/cyrax/
|
160
|
+
- spec/cyrax/extensions/has_decorator_spec.rb
|
161
|
+
- spec/cyrax/extensions/has_response_spec.rb
|
166
162
|
- spec/cyrax/response_spec.rb
|
167
163
|
- spec/cyrax/serializer_spec.rb
|
164
|
+
- spec/cyrax/resource_spec.rb
|
165
|
+
- spec/cyrax/base_spec.rb
|
166
|
+
- spec/cyrax/decorator_spec.rb
|
168
167
|
- spec/spec_helper.rb
|