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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 88a478d9713a8699d9cb95ba18a3b5484b678112
4
- data.tar.gz: 2589fbbf6e1a07dc300bcede1d45008d7123cc6e
3
+ metadata.gz: bbb96f7788da37f889f320a1f37d8e7ca37ea510
4
+ data.tar.gz: 20bf1cb7ecc856907df5a27d8a5f983c04902336
5
5
  SHA512:
6
- metadata.gz: cc9476fe7c40cfee230dcc239e7e19ce45a11008903360ffae93d0e004963c713ef401d5313bc34479ad7d5b965cbb9a4e334e34532ad13114f18cd505206919
7
- data.tar.gz: b104a3ec1b2a4df86badbb7f81a262ed7800735e08ef188fd05583964790241ec09eb1049b8d69ab2a55a8c33cb55b36d08966d179aca9ea4fe5e5ef5db3fa16
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 featers for server-side rendered views |
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? action_params_method, true
106
+ if respond_to?(action_params_method, true)
107
107
  send(action_params_method)
108
- elsif respond_to? model_params_method, true
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
- return if qualified_name.blank?
47
- klass = qualified_name.safe_constantize
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
- return if qualified_name.blank?
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
- return if qualified_name.blank?
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
@@ -17,7 +17,6 @@ module SkinnyControllers
17
17
  namespaces.each do |namespace|
18
18
  current = (existing + [namespace]).join('::')
19
19
  begin
20
- # binding.pry
21
20
  Object.const_get(current)
22
21
  rescue NameError
23
22
  SkinnyControllers.logger.warn("Module #{namespace} not found, creating...")
@@ -22,8 +22,8 @@ module SkinnyControllers
22
22
  :_lookup
23
23
 
24
24
  class << self
25
- def run(current_user, params)
26
- object = new(current_user, params)
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(
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module SkinnyControllers
3
- VERSION = '0.10.2'
3
+ VERSION = '0.10.3'
4
4
  end
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.2
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: 2016-12-01 00:00:00.000000000 Z
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.5.1
238
+ rubygems_version: 2.6.11
239
239
  signing_key:
240
240
  specification_version: 4
241
- summary: SkinnyControllers-0.10.2
241
+ summary: SkinnyControllers-0.10.3
242
242
  test_files: []
243
- has_rdoc: