skinny_controllers 0.10.2 → 0.10.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/skinny_controllers/diet.rb +2 -2
- data/lib/skinny_controllers/lookup/ensure_existence.rb +16 -8
- data/lib/skinny_controllers/lookup/namespace.rb +0 -1
- data/lib/skinny_controllers/operation/base.rb +14 -4
- data/lib/skinny_controllers/version.rb +1 -1
- metadata +4 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bbb96f7788da37f889f320a1f37d8e7ca37ea510
|
4
|
+
data.tar.gz: 20bf1cb7ecc856907df5a27d8a5f983c04902336
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f732c190f25ddb33ac707d3dd4f14edbd010f3a53974cb776e02a5abfa153980da9a1f7343050babd72b64baff86503258eddb7d39ecd3d303e19d521d00d9db
|
7
|
+
data.tar.gz: 43e3c08f3d80b0a4f3ef53b71513514e3084f507c77df1ab7306690ff1beb3f1ba2e670c5bf054092badd94732bdc1125bea4e564b5d894d21c9bc6426afb6ff
|
data/README.md
CHANGED
@@ -543,7 +543,7 @@ This may not be horribly apparent, but here is a table overviewing some highleve
|
|
543
543
|
|
544
544
|
| Feature | - | skinny_controllers | [trailblazer](https://github.com/apotonick/trailblazer) |
|
545
545
|
|----|----|----|----|
|
546
|
-
| Purpose |-| API - works very well with [ActiveModel::Serializers](https://github.com/rails-api/active_model_serializers)| General - additional
|
546
|
+
| Purpose |-| API - works very well with [ActiveModel::Serializers](https://github.com/rails-api/active_model_serializers)| General - additional features for server-side rendered views |
|
547
547
|
| Added Layers |-| Operations, Policies | Operations, Policies, Forms |
|
548
548
|
| Validation |-| stay in models | moved to operations via contract block |
|
549
549
|
| Additional objects|-| none | contacts, representers, callbacks, cells |
|
@@ -103,9 +103,9 @@ module SkinnyControllers
|
|
103
103
|
action_params_method = "#{action_name}_#{model_key}_params"
|
104
104
|
model_params_method = "#{model_key}_params"
|
105
105
|
|
106
|
-
if respond_to?
|
106
|
+
if respond_to?(action_params_method, true)
|
107
107
|
send(action_params_method)
|
108
|
-
elsif respond_to?
|
108
|
+
elsif respond_to?(model_params_method, true)
|
109
109
|
send(model_params_method)
|
110
110
|
else
|
111
111
|
params
|
@@ -1,5 +1,7 @@
|
|
1
1
|
module SkinnyControllers
|
2
2
|
class Lookup
|
3
|
+
# NOTE: This is a lot of hackery.
|
4
|
+
# Please Explicitly Define things if you are able
|
3
5
|
module EnsureExistence
|
4
6
|
module_function
|
5
7
|
|
@@ -43,8 +45,9 @@ module SkinnyControllers
|
|
43
45
|
end
|
44
46
|
|
45
47
|
def namespace_lookup(qualified_name)
|
46
|
-
|
47
|
-
|
48
|
+
klass = class_for_qualified_name(qualified_name)
|
49
|
+
# Return if the constant exists, or if we can't travel
|
50
|
+
# up any higher.
|
48
51
|
return klass if klass
|
49
52
|
return unless qualified_name.include?('::')
|
50
53
|
|
@@ -65,9 +68,7 @@ module SkinnyControllers
|
|
65
68
|
end
|
66
69
|
|
67
70
|
def policy_lookup(qualified_name)
|
68
|
-
|
69
|
-
klass = qualified_name.safe_constantize
|
70
|
-
|
71
|
+
klass = class_for_qualified_name(qualified_name)
|
71
72
|
# Return if the constant exists, or if we can't travel
|
72
73
|
# up any higher.
|
73
74
|
return klass if klass
|
@@ -87,9 +88,7 @@ module SkinnyControllers
|
|
87
88
|
end
|
88
89
|
|
89
90
|
def operation_lookup(qualified_name)
|
90
|
-
|
91
|
-
klass = qualified_name.safe_constantize
|
92
|
-
|
91
|
+
klass = class_for_qualified_name(qualified_name)
|
93
92
|
# Return if the constant exists, or if we can't travel
|
94
93
|
# up any higher.
|
95
94
|
return klass if klass
|
@@ -113,5 +112,14 @@ module SkinnyControllers
|
|
113
112
|
# recurse
|
114
113
|
operation_lookup(next_lookup)
|
115
114
|
end
|
115
|
+
|
116
|
+
private
|
117
|
+
|
118
|
+
def class_for_qualified_name(qualified_name)
|
119
|
+
# Validate the name.
|
120
|
+
return if qualified_name.blank?
|
121
|
+
|
122
|
+
qualified_name.safe_constantize
|
123
|
+
end
|
116
124
|
end
|
117
125
|
end
|
@@ -22,8 +22,8 @@ module SkinnyControllers
|
|
22
22
|
:_lookup
|
23
23
|
|
24
24
|
class << self
|
25
|
-
def run(
|
26
|
-
object = new(
|
25
|
+
def run(*args)
|
26
|
+
object = new(*args)
|
27
27
|
object.run
|
28
28
|
end
|
29
29
|
|
@@ -50,17 +50,27 @@ module SkinnyControllers
|
|
50
50
|
action = nil,
|
51
51
|
lookup = nil,
|
52
52
|
options = {})
|
53
|
+
|
54
|
+
|
55
|
+
|
53
56
|
self.authorized_via_parent = false
|
54
57
|
self.current_user = current_user
|
55
58
|
self.action = action || controller_params[:action]
|
56
|
-
self.params = controller_params
|
57
|
-
self.params_for_action = params_for_action || controller_params
|
59
|
+
self.params = params_to_hash(controller_params)
|
60
|
+
self.params_for_action = params_to_hash(params_for_action || controller_params)
|
61
|
+
|
58
62
|
self._lookup = lookup
|
59
63
|
self.options = options
|
60
64
|
self.model_key = options[:model_params_key]
|
61
65
|
self.association_name = options[:association_name]
|
62
66
|
end
|
63
67
|
|
68
|
+
def params_to_hash(parameters)
|
69
|
+
return parameters.to_unsafe_hash if parameters.respond_to?(:to_unsafe_hash)
|
70
|
+
|
71
|
+
parameters.to_h
|
72
|
+
end
|
73
|
+
|
64
74
|
def lookup
|
65
75
|
@lookup ||= begin
|
66
76
|
_lookup || Lookup.from_operation(
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: skinny_controllers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- L. Preston Sego III
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-07-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -235,9 +235,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
235
235
|
version: '0'
|
236
236
|
requirements: []
|
237
237
|
rubyforge_project:
|
238
|
-
rubygems_version: 2.
|
238
|
+
rubygems_version: 2.6.11
|
239
239
|
signing_key:
|
240
240
|
specification_version: 4
|
241
|
-
summary: SkinnyControllers-0.10.
|
241
|
+
summary: SkinnyControllers-0.10.3
|
242
242
|
test_files: []
|
243
|
-
has_rdoc:
|