inherited_resources 1.6.0 → 1.7.0

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: 4a8ecdfec2db9c75ad03674c7a299777858f9d9e
4
- data.tar.gz: e98f948659ee83a8f939d25f3f65545a6bfce8ad
3
+ metadata.gz: c29a882f1b539c21b739478231165d73d23e0342
4
+ data.tar.gz: 4f2ef22ade978647e66640a6955a118e82f89af5
5
5
  SHA512:
6
- metadata.gz: c62f90fc082c373908ef03d428571f5ab773ae1c6d37d26c2dbde54a08c3799102adf3a4bca50c3b367e4f7cb5333182820bacff4b6592df5a0772d82aec302d
7
- data.tar.gz: 0c5d1d18700eaeb3c97e2eb4d6f60c2e7d72d3306417e237ecc2c5b781d0c47d40120e58dbc6631532e6cde079f978e36039f2630a8e476df8b6db170c1a7d9b
6
+ metadata.gz: a92f1ed2578bf0dd95973e5bdb95d5397d5cc00edf3b566a86ae4718f22861898094311cce0eee77b21f4cb9166ca6c87e0cba74743f0f1af67838d74efa4334
7
+ data.tar.gz: 2741b0b1712fe05728038baf22239b096941c2423ca059e530f3e245354022073427228823899c58eb7cf45b570d909fbd4d83daf7436096eb7d131c55e61c95
data/README.md CHANGED
@@ -1,14 +1,17 @@
1
- ## Deprecation notice
1
+ ## Notice
2
2
 
3
- Since Rails 3 came out, I have no longer used Inherited Resources and it is no
4
- longer actively maintained. I have found that the responders abstraction
5
- offers the perfect balance between hiding and showing too much logic in controllers.
6
- That said, I suggest developers to make use of Rails' `respond_with` feature
7
- alongside the [responders gem](https://github.com/plataformatec/responders) as a
8
- replacement to Inherited Resources.
3
+ Inherited Resources is no longer actively maintained by the original author and
4
+ has been transferred to the ActiveAdmin organization for maintenance. New feature
5
+ requests are not encouraged.
6
+
7
+ If you are not already using Inherited Resources we suggest instead using Rails'
8
+ `respond_with` feature alongside the [responders gem](https://github.com/plataformatec/responders).
9
9
 
10
10
  ## Inherited Resources
11
11
 
12
+ [![Version ](http://img.shields.io/gem/v/inherited_resources.svg) ](https://rubygems.org/gems/inherited_resources)
13
+ [![Travis CI ](http://img.shields.io/travis/activeadmin/inherited_resources/master.svg) ](https://travis-ci.org/activeadmin/inherited_resources)
14
+
12
15
  Inherited Resources speeds up development by making your controllers inherit
13
16
  all restful actions so you just have to focus on what is important. It makes
14
17
  your controllers more powerful and cleaner at the same time.
@@ -22,8 +25,6 @@ two screencasts available besides this README:
22
25
 
23
26
  ## Installation
24
27
 
25
- ### Rails 3
26
-
27
28
  You can let bundler install Inherited Resources by adding this line to your application's Gemfile:
28
29
 
29
30
  ```ruby
@@ -42,20 +43,6 @@ Or install it yourself with:
42
43
  $ gem install inherited_resources
43
44
  ```
44
45
 
45
- ### Rails 2.3.x
46
-
47
- If you want to use the Rails 2.3.x version, you should install:
48
-
49
- ```sh
50
- $ gem install inherited_resources --version=1.0.6
51
- ```
52
-
53
- Or checkout from the v1.0 branch:
54
-
55
- ```
56
- http://github.com/josevalim/inherited_resources/tree/v1.0
57
- ```
58
-
59
46
  ## HasScope
60
47
 
61
48
  Since Inherited Resources 1.0, has_scope is not part of its core anymore but
@@ -428,7 +415,7 @@ end
428
415
  ```
429
416
 
430
417
  It also accepts `:route_name`, `:parent_class` and `:instance_name` as options.
431
- Check the [lib/inherited_resources/class_methods.rb](https://github.com/josevalim/inherited_resources/blob/master/lib/inherited_resources/class_methods.rb)
418
+ Check the [lib/inherited_resources/class_methods.rb](https://github.com/activeadmin/inherited_resources/blob/master/lib/inherited_resources/class_methods.rb)
432
419
  for more.
433
420
 
434
421
  ## Nested belongs to
@@ -655,7 +642,7 @@ index actions accordingly). Also, it will produce `delete_resource_{path,url}` a
655
642
  Sometimes just DRYing up the controllers is not enough. If you need to DRY up your views,
656
643
  check this Wiki page:
657
644
 
658
- https://github.com/josevalim/inherited_resources/wiki/Views-Inheritance
645
+ https://github.com/activeadmin/inherited_resources/wiki/Views-Inheritance
659
646
 
660
647
 
661
648
  Notice that Rails 3.1 ships with view inheritance built-in.
@@ -2,7 +2,7 @@
2
2
  require 'inherited_resources/blank_slate'
3
3
 
4
4
  module InheritedResources
5
- # Base helpers for InheritedResource work. Some methods here can be overwriten
5
+ # Base helpers for InheritedResource work. Some methods here can be overwritten
6
6
  # and you will need to do that to customize your controllers from time to time.
7
7
  #
8
8
  module BaseHelpers
@@ -75,7 +75,7 @@ module InheritedResources
75
75
 
76
76
  # Responsible for updating the resource in :update method. This allow you
77
77
  # to handle how the resource is going to be updated, let's say in a different
78
- # way then the usual :update_attributes:
78
+ # way than the usual :update_attributes:
79
79
  #
80
80
  # def update_resource(object, attributes)
81
81
  # object.reset_password!(attributes)
@@ -86,7 +86,7 @@ module InheritedResources
86
86
  end
87
87
 
88
88
  # Handle the :destroy method for the resource. Overwrite it to call your
89
- # own method for destroing the resource, as:
89
+ # own method for destroying the resource, as:
90
90
  #
91
91
  # def destroy_resource(object)
92
92
  # object.cancel
@@ -123,7 +123,7 @@ module InheritedResources
123
123
  end
124
124
 
125
125
  # Returns if the controller has a parent. When only base helpers are loaded,
126
- # it's always false and should not be overwriten.
126
+ # it's always false and should not be overwritten.
127
127
  #
128
128
  def parent?
129
129
  false
@@ -184,7 +184,7 @@ module InheritedResources
184
184
  apply_scopes_if_available(chain.send(method_for_association_chain))
185
185
  else
186
186
  # This only happens when we specify begin_of_association_chain in
187
- # a singletion controller without parents. In this case, the chain
187
+ # a singleton controller without parents. In this case, the chain
188
188
  # is exactly the begin_of_association_chain which is already an
189
189
  # instance and then not scopable.
190
190
  chain
@@ -200,7 +200,7 @@ module InheritedResources
200
200
  (begin_of_association_chain || parent?) ? method_for_association_build : :new
201
201
  end
202
202
 
203
- # Returns the name of the method used for build the resource in cases
203
+ # Returns the name of the method used for building the resource in cases
204
204
  # where we have a parent. This is overwritten in singleton scenarios.
205
205
  #
206
206
  def method_for_association_build
@@ -208,7 +208,7 @@ module InheritedResources
208
208
  end
209
209
 
210
210
  # Returns the name of the method to be called, before returning the end
211
- # of the association chain. This is overwriten by singleton cases
211
+ # of the association chain. This is overwritten by singleton cases
212
212
  # where no method for association chain is called.
213
213
  #
214
214
  def method_for_association_chain #:nodoc:
@@ -223,7 +223,8 @@ module InheritedResources
223
223
  # Get resource ivar based on the current resource controller.
224
224
  #
225
225
  def get_resource_ivar #:nodoc:
226
- instance_variable_get("@#{resource_instance_name}")
226
+ instance_variable_defined?(:"@#{resource_instance_name}") &&
227
+ instance_variable_get("@#{resource_instance_name}")
227
228
  end
228
229
 
229
230
  # Set resource ivar based on the current resource controller.
@@ -235,7 +236,8 @@ module InheritedResources
235
236
  # Get collection ivar based on the current resource controller.
236
237
  #
237
238
  def get_collection_ivar #:nodoc:
238
- instance_variable_get("@#{resource_collection_name}")
239
+ instance_variable_defined?(:"@#{resource_collection_name}") &&
240
+ instance_variable_get("@#{resource_collection_name}")
239
241
  end
240
242
 
241
243
  # Set collection ivar based on the current resource controller.
@@ -283,7 +285,7 @@ module InheritedResources
283
285
  respond_to?(:apply_scopes, true) ? apply_scopes(target_object) : target_object
284
286
  end
285
287
 
286
- # Symbols chain in base helpers return nothing. This is later overwriten
288
+ # Symbols chain in base helpers return nothing. This is later overwritten
287
289
  # by belongs_to and can be complex in polymorphic cases.
288
290
  #
289
291
  def symbols_for_association_chain #:nodoc:
@@ -71,9 +71,16 @@ module InheritedResources
71
71
  # association chain.
72
72
  #
73
73
  def evaluate_parent(parent_symbol, parent_config, chain = nil) #:nodoc:
74
- instantiated_object = instance_variable_get("@#{parent_config[:instance_name]}")
75
- return instantiated_object if instantiated_object
74
+ get_parent_ivar(parent_config[:instance_name]) ||
75
+ set_parent_instance(parent_config, chain)
76
+ end
77
+
78
+ def get_parent_ivar(instance_name)
79
+ instance_variable_defined?(:"@#{instance_name}") &&
80
+ instance_variable_get("@#{instance_name}")
81
+ end
76
82
 
83
+ def set_parent_instance(parent_config, chain)
77
84
  if parent_config[:singleton]
78
85
  parent = if chain
79
86
  chain.send(parent_config[:instance_name])
@@ -363,6 +363,16 @@ module InheritedResources
363
363
 
364
364
  # Deal with namespaced controllers
365
365
  namespaces = self.controller_path.split('/')[0..-2]
366
+
367
+ # Remove namespace if its a mountable engine
368
+ namespaces.delete_if do |namespace|
369
+ begin
370
+ "#{namespace}/engine".camelize.constantize.isolated?
371
+ rescue StandardError, LoadError
372
+ false
373
+ end
374
+ end
375
+
366
376
  config[:route_prefix] = namespaces.join('_') unless namespaces.empty?
367
377
 
368
378
  # Deal with default request parameters in namespaced controllers, e.g.
@@ -218,11 +218,13 @@ module InheritedResources
218
218
 
219
219
  class_eval <<-URL_HELPERS, __FILE__, __LINE__
220
220
  protected
221
+ undef :#{prefix}#{name}_path if method_defined? :#{prefix}#{name}_path
221
222
  def #{prefix}#{name}_path(*given_args)
222
223
  given_options = given_args.extract_options!
223
224
  #{prefix}#{segments}_path(#{ivars})
224
225
  end
225
226
 
227
+ undef :#{prefix}#{name}_url if method_defined? :#{prefix}#{name}_url
226
228
  def #{prefix}#{name}_url(*given_args)
227
229
  given_options = given_args.extract_options!
228
230
  #{prefix}#{segments}_url(#{ivars})
@@ -1,3 +1,3 @@
1
1
  module InheritedResources
2
- VERSION = '1.6.0'.freeze
2
+ VERSION = '1.7.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inherited_resources
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - José Valim
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-01-21 00:00:00.000000000 Z
12
+ date: 2017-01-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: responders
@@ -34,7 +34,7 @@ dependencies:
34
34
  version: '3.2'
35
35
  - - "<"
36
36
  - !ruby/object:Gem::Version
37
- version: '5'
37
+ version: '5.1'
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
@@ -44,7 +44,7 @@ dependencies:
44
44
  version: '3.2'
45
45
  - - "<"
46
46
  - !ruby/object:Gem::Version
47
- version: '5'
47
+ version: '5.1'
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: railties
50
50
  requirement: !ruby/object:Gem::Requirement
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '3.2'
55
55
  - - "<"
56
56
  - !ruby/object:Gem::Version
57
- version: '5'
57
+ version: '5.1'
58
58
  type: :runtime
59
59
  prerelease: false
60
60
  version_requirements: !ruby/object:Gem::Requirement
@@ -64,21 +64,21 @@ dependencies:
64
64
  version: '3.2'
65
65
  - - "<"
66
66
  - !ruby/object:Gem::Version
67
- version: '5'
67
+ version: '5.1'
68
68
  - !ruby/object:Gem::Dependency
69
69
  name: has_scope
70
70
  requirement: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
- version: 0.6.0.rc
74
+ version: '0.6'
75
75
  type: :runtime
76
76
  prerelease: false
77
77
  version_requirements: !ruby/object:Gem::Requirement
78
78
  requirements:
79
79
  - - "~>"
80
80
  - !ruby/object:Gem::Version
81
- version: 0.6.0.rc
81
+ version: '0.6'
82
82
  description: Inherited Resources speeds up development by making your controllers
83
83
  inherit all restful actions so you just have to focus on what is important.
84
84
  email:
@@ -105,7 +105,7 @@ files:
105
105
  - lib/inherited_resources/singleton_helpers.rb
106
106
  - lib/inherited_resources/url_helpers.rb
107
107
  - lib/inherited_resources/version.rb
108
- homepage: http://github.com/josevalim/inherited_resources
108
+ homepage: http://github.com/activeadmin/inherited_resources
109
109
  licenses:
110
110
  - MIT
111
111
  metadata: {}
@@ -117,7 +117,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
117
117
  requirements:
118
118
  - - ">="
119
119
  - !ruby/object:Gem::Version
120
- version: '0'
120
+ version: '2.1'
121
121
  required_rubygems_version: !ruby/object:Gem::Requirement
122
122
  requirements:
123
123
  - - ">="
@@ -125,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
125
  version: '0'
126
126
  requirements: []
127
127
  rubyforge_project: inherited_resources
128
- rubygems_version: 2.4.5
128
+ rubygems_version: 2.6.10
129
129
  signing_key:
130
130
  specification_version: 4
131
131
  summary: Inherited Resources speeds up development by making your controllers inherit