restful_json 3.3.3 → 3.3.4

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YWE3ZThlMmNjMjNkNTgyYjVhMmE0Mjk4NzgyZTljNjI5NWEwYzRmZA==
4
+ MGQzMzcyMzc1ZDdjMTQ2NTk2NzBhZGUwMDQzOTM3ZTIyMWU0MGEzNA==
5
5
  data.tar.gz: !binary |-
6
- ZjkzZjY5YThhOGFiYmY1MGE2NWZjYTEwMTQ3NWViMTZlMjVjOWNiMQ==
6
+ MDNkZmFjZDdkOGQ4YzkxMWJkNzc1NjBlZmYwYjcwODhkODBkNjMxNw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NjE5OGM5NWU5ZWFmNGZiZDRjZjUyNDAxOGM5MDRlOWQ2NzVjOWMzNzNiMDMz
10
- MWUyOGUxMmNkNWM0OTJjZTNmY2RjMGQ2YmJkZGExNDZmMDhiMTRkMmQzMDk1
11
- NDMxZTM5NzVlZTNkYzI1NWNiYjZkZmVhYzFhNDllMGY2Y2UzZDI=
9
+ MTgyMjc3OGMzYzZiZjE4Y2FkMjJlYjk4Mzc1ZmU0YjIzMDdiYjBmZWYzZmYw
10
+ MDFlMGQzZWU0Y2VhNjdkNzNiYTBhNzZhYWY3YzE1OTZiNTgzMmZkYmQyMDk1
11
+ NzQ1ZmY1ZmVkOTI0MTRjZWZiODRiNzJhYzU1MzI5YWFkN2FkOTE=
12
12
  data.tar.gz: !binary |-
13
- NDgyM2RmNzRhZTdmNjcxZWZkMzg4OWM3MWYxMDVhOTUwYTQ5MjcyZDQ3ZjFi
14
- YTFhZGY5NjVlMmE5ZWE3MDdlODgyNzdmM2Q1ODkwMjNmYzIzY2JkNWUyNWQ2
15
- ZWI4NWEyN2ViZmYwMzExMTVhNmRhNjkyMjE2OGQxZGE5MzBjZGM=
13
+ OWNhMDhhODdhZjU4ZTA0MDMzNjRlOGM3NGEzYTlkNmQzNmFiMGZjMzYxZDM0
14
+ NjY3ZjNmOGM3YjgzMDQ5N2Y2ZjQ5YjE0ZWZjYWNhYzlhMWNlODk4ZGNkYWE3
15
+ NTAxNTI4YTAzOTAyOWNmNGE1NGI1ZGVjYzYzMDA1NTVjZjI3ZmI=
@@ -44,7 +44,6 @@ module RestfulJson
44
44
  class_attribute :action_to_serializer_for, instance_writer: true
45
45
 
46
46
  # use values from config
47
- # debug uses RestfulJson.debug? because until this is done no local debug class attribute exists to check
48
47
  RestfulJson::CONTROLLER_OPTIONS.each do |key|
49
48
  class_attribute key, instance_writer: true
50
49
  self.send("#{key}=".to_sym, RestfulJson.send(key))
@@ -240,6 +239,8 @@ module RestfulJson
240
239
  #
241
240
  # Note: this method be alias_method'd by query_for, so it is more than just index.
242
241
  def index
242
+ # could be index or another action if alias_method'd by query_for
243
+ logger.debug "#{params[:action].to_s} called in #{self.class}: model=#{@model_class}, request.format=#{request.format}, request.content_type=#{request.content_type}, params=#{params.inspect}" if self.debug
243
244
  t = @model_class.arel_table
244
245
  value = @model_class.scoped # returns ActiveRecord::Relation equivalent to select with no where clause
245
246
  custom_query = self.action_to_query[params[:action].to_s]
@@ -344,6 +345,7 @@ module RestfulJson
344
345
 
345
346
  # The controller's show (get) method to return a resource.
346
347
  def show
348
+ logger.debug "#{params[:action].to_s} called in #{self.class}: model=#{@model_class}, request.format=#{request.format}, request.content_type=#{request.content_type}, params=#{params.inspect}" if self.debug
347
349
  # to_s as safety measure for vulnerabilities similar to CVE-2013-1854
348
350
  @value = @model_class.where(id: params[:id].to_s).first # don't raise exception if not found
349
351
  instance_variable_set(@model_at_singular_name_sym, @value)
@@ -352,6 +354,7 @@ module RestfulJson
352
354
 
353
355
  # The controller's new method (e.g. used for new record in html format).
354
356
  def new
357
+ logger.debug "#{params[:action].to_s} called in #{self.class}: model=#{@model_class}, request.format=#{request.format}, request.content_type=#{request.content_type}, params=#{params.inspect}" if self.debug
355
358
  @value = @model_class.new
356
359
  instance_variable_set(@model_at_singular_name_sym, @value)
357
360
  render_or_respond(true)
@@ -359,6 +362,7 @@ module RestfulJson
359
362
 
360
363
  # The controller's edit method (e.g. used for edit record in html format).
361
364
  def edit
365
+ logger.debug "#{params[:action].to_s} called in #{self.class}: model=#{@model_class}, request.format=#{request.format}, request.content_type=#{request.content_type}, params=#{params.inspect}" if self.debug
362
366
  # to_s as safety measure for vulnerabilities similar to CVE-2013-1854
363
367
  @value = @model_class.where(id: params[:id].to_s).first! # raise exception if not found
364
368
  instance_variable_set(@model_at_singular_name_sym, @value)
@@ -367,6 +371,7 @@ module RestfulJson
367
371
 
368
372
  # The controller's create (post) method to create a resource.
369
373
  def create
374
+ logger.debug "#{params[:action].to_s} called in #{self.class}: model=#{@model_class}, request.format=#{request.format}, request.content_type=#{request.content_type}, params=#{params.inspect}" if self.debug
370
375
  if self.use_permitters
371
376
  authorize! :create, @model_class
372
377
  allowed_params = permitted_params
@@ -385,6 +390,7 @@ module RestfulJson
385
390
 
386
391
  # The controller's update (put) method to update a resource.
387
392
  def update
393
+ logger.debug "#{params[:action].to_s} called in #{self.class}: model=#{@model_class}, request.format=#{request.format}, request.content_type=#{request.content_type}, params=#{params.inspect}" if self.debug
388
394
  if self.use_permitters
389
395
  authorize! :update, @model_class
390
396
  allowed_params = permitted_params
@@ -404,11 +410,19 @@ module RestfulJson
404
410
 
405
411
  # The controller's destroy (delete) method to destroy a resource.
406
412
  def destroy
413
+ logger.debug "#{params[:action].to_s} called in #{self.class}: model=#{@model_class}, request.format=#{request.format}, request.content_type=#{request.content_type}, params=#{params.inspect}" if self.debug
407
414
  # to_s as safety measure for vulnerabilities similar to CVE-2013-1854
408
415
  @value = @model_class.where(id: params[:id].to_s).first # don't raise exception
409
416
  @value.destroy if @value
410
417
  instance_variable_set(@model_at_singular_name_sym, @value)
411
- render_or_respond(false)
418
+ if !@value.respond_to?(:errors) || @value.errors.empty? || (request.format != 'text/html' && request.content_type != 'text/html')
419
+ # don't require a destroy view for success, because it isn't implements in Rails by default for json
420
+ respond_to do |format|
421
+ format.any { head :ok }
422
+ end
423
+ else
424
+ render_or_respond(false)
425
+ end
412
426
  end
413
427
  end
414
428
  end
@@ -1,3 +1,3 @@
1
1
  module RestfulJson
2
- VERSION = '3.3.3'
2
+ VERSION = '3.3.4'
3
3
  end
@@ -29,7 +29,7 @@ module TwinTurbo
29
29
  rescue NameError
30
30
  end
31
31
  end
32
- puts "Could not find permitter: #{permitter_class_arr.collect{|c|c.to_s}.join(', ')}" if RestfulJson.debug?
32
+ logger.debug "Could not find permitter: #{permitter_class_arr.collect{|c|c.to_s}.join(', ')}" if RestfulJson.debug?
33
33
  nil
34
34
  end
35
35
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: restful_json
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.3
4
+ version: 3.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gary S. Weaver
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-11 00:00:00.000000000 Z
12
+ date: 2013-04-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler