skinny_controllers 0.9.0 → 0.9.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f20c80e6d30015ce35842974c6ce2bc4b559034f
4
- data.tar.gz: d43809e60ad51ec26de9a1e329c6ec7c4d1a381b
3
+ metadata.gz: 3b575298d306f70673c3492426f7cbd3392224f6
4
+ data.tar.gz: 357abe13b4b4904ea205a9d85d7c9b840b7a3937
5
5
  SHA512:
6
- metadata.gz: e059c8cf6a99882880258002dab529e429929fc98b165a69ff3b24990fd18b7b2a5b3380e7e6973daf83323ece699b4afda8de96d958d3af05432726c542300b
7
- data.tar.gz: d6928db4a0884a190aabd50a1195f179b7f6aed7782742130ca5ed63d3bd37025a739f3288ecac98303201fd63f103c024c9605fb7bf69f4ec333dcc9cc596fd
6
+ metadata.gz: ea1b346a06c1ae864099ae64b701342d2f1ae5446611121772f997a7e385bab6805270f242656c608cf7dc38b30f66ff398f35111fc8516aa2ea5c275de44a00
7
+ data.tar.gz: bd92722968b07d001a70482ea035a4f490534b8cbe253164daea53c8afb10a6258a641f460d6400f573d493ae73ca50fcc8a7112153fb8162ed6a5f362c81ab3
data/README.md CHANGED
@@ -117,7 +117,7 @@ end
117
117
  ```
118
118
  `model_key` specifies the key to look for params when creating / updating the model.
119
119
 
120
- Note that while `model_key` doesn't *have* to be specified, it would default to name_space/item. So, just keep that in mind.
120
+ Note that while `model_key` doesn't *have* to be specified, it would default to name_space/item. So, just keep that in mind.
121
121
 
122
122
  ### What if you want to call your own operations?
123
123
 
@@ -7,6 +7,7 @@ module SkinnyControllers
7
7
  class << self
8
8
  attr_accessor :model_class
9
9
  attr_accessor :model_key
10
+ attr_accessor :association_name
10
11
  end
11
12
  end
12
13
 
@@ -18,7 +19,8 @@ module SkinnyControllers
18
19
  current_user,
19
20
  params, params_for_action,
20
21
  action_name, self.class.model_key,
21
- _lookup
22
+ _lookup,
23
+ self.class.association_name
22
24
  )
23
25
  end
24
26
 
@@ -17,7 +17,9 @@ module SkinnyControllers
17
17
  include ModelHelpers
18
18
 
19
19
  attr_accessor :params, :current_user, :authorized_via_parent,
20
- :action, :params_for_action, :model_key, :_lookup
20
+ :action, :params_for_action, :model_key,
21
+ :association_name,
22
+ :_lookup
21
23
 
22
24
  class << self
23
25
  def run(current_user, params)
@@ -37,12 +39,16 @@ module SkinnyControllers
37
39
  # e.g.: MyOperation.new().()
38
40
  alias_method :call, :run
39
41
 
42
+ # TODO: too many *optional* parameters. Group into options hash
43
+ #
40
44
  # @param [Model] current_user the logged in user
41
45
  # @param [Hash] controller_params the params hash raw from the controller
42
46
  # @param [Hash] params_for_action optional params hash, generally the result of strong parameters
43
47
  # @param [string] action the current action on the controller
44
- def initialize(current_user, controller_params, params_for_action = nil, action = nil,
45
- model_key = nil, lookup = nil)
48
+ def initialize(current_user, controller_params,
49
+ params_for_action = nil, action = nil,
50
+ model_key = nil, lookup = nil,
51
+ association_name = nil)
46
52
  self.authorized_via_parent = false
47
53
  self.current_user = current_user
48
54
  self.action = action || controller_params[:action]
@@ -50,6 +56,7 @@ module SkinnyControllers
50
56
  self.params_for_action = params_for_action || controller_params
51
57
  self.model_key = model_key
52
58
  self._lookup = lookup
59
+ self.association_name = association_name
53
60
  end
54
61
 
55
62
  def lookup
@@ -81,7 +88,7 @@ module SkinnyControllers
81
88
  #
82
89
  # TODO: maybe make this configurable?
83
90
  def association_name_from_object
84
- model_name.tableize.split('/').last
91
+ association_name || model_name.tableize.split('/').last
85
92
  end
86
93
 
87
94
  # @return a new policy object and caches it
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module SkinnyControllers
3
- VERSION = '0.9.0'.freeze
3
+ VERSION = '0.9.1'
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.9.0
4
+ version: 0.9.1
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-10-31 00:00:00.000000000 Z
11
+ date: 2016-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -235,8 +235,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
235
235
  version: '0'
236
236
  requirements: []
237
237
  rubyforge_project:
238
- rubygems_version: 2.6.7
238
+ rubygems_version: 2.5.1
239
239
  signing_key:
240
240
  specification_version: 4
241
- summary: SkinnyControllers-0.9.0
241
+ summary: SkinnyControllers-0.9.1
242
242
  test_files: []
243
+ has_rdoc: