abstracted 0.4.16 → 0.4.17

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: e2829d61f4582508364fcbb86f3dc3f6e36f29c6
4
- data.tar.gz: de3dd1080aa08996d921144ef1cded25eb74190a
3
+ metadata.gz: 3768a2fd0bc32496836612516717cd03550edb9a
4
+ data.tar.gz: a57bc2f9df972dc31cc87d696a111c36c6d67cf3
5
5
  SHA512:
6
- metadata.gz: 48cd810f19699a6a154fd5c79e72bafbac130f7840b23bcde783539fd291129783dfec5089e37629747edff3a940ca36b5403b05b7cb536972e52074df518a52
7
- data.tar.gz: 08ccfe7d563382d9f79bda47bfa9c3e2ac4440f8a3cdb2c7d63d2800959c7987b0d0d18946dfb13302a55af641f99c625a6202ca6ded9ae7e3c93ae51ef87798
6
+ metadata.gz: f8b7ed7d8e12fdd28b00ff5a8067b2847a751e4faf81e71c6e6207b4521031901108027d2c46b8d881abf6b47ca49ed956d1a4780b3a49302f64338c5d46bed6
7
+ data.tar.gz: 07263ffc2f2fa4eb11733b12aa89ec48fbbb27ac3a665c407c365c102a3548bd0173da12645623db33724abae22f047a98d40bbf0aa34de53b5beaba44a683ea
@@ -229,7 +229,9 @@ class AbstractResourcesController < ApplicationController
229
229
 
230
230
 
231
231
  def scoop_from_error e
232
+
232
233
  raise e if %w{ test development }.include? Rails.env
234
+
233
235
  logger.debug "AbstractResourcesController##{params[:action]}: #{e.class}"
234
236
  a_url = root_path
235
237
 
@@ -317,4 +319,9 @@ class AbstractResourcesController < ApplicationController
317
319
 
318
320
  end
319
321
 
322
+ def error_counter
323
+ @error_counter ||= 0
324
+ @error_counter = @error_counter + 1
325
+ end
326
+
320
327
  end
@@ -70,13 +70,27 @@ module AbstractResourcesHelper
70
70
  #
71
71
  # resource_url returns the current entity's url
72
72
  def resource_url options={}
73
- opt = {}
74
- opt[:id] = options.id if options.class.ancestors.include? ActiveRecord::Base # edit_resource_url(@post)
75
- opt.merge!(options) if options.class==Hash
76
- opt[:action] ||= 'show'
77
- opt[:id] ||= resource.id
78
- opt[:controller] ||= resource_class.table_name
79
- url_for opt
73
+ r=request.path
74
+ id=params[:id]
75
+ options = case params[:action]
76
+ when 'create','update','delete','destroy'; ""
77
+ else resource_options(options)
78
+ end
79
+ return "%s%s" % [r,options] if r.match "\/#{resource.class.to_s.tableize}\/#{id}(|\/#{params[:action]})$"
80
+ "%s%s" % [ r.split("/#{params[:action]}")[0], options]
81
+
82
+ # opt = {}
83
+ # opt[:id] = options.id if options.class.ancestors.include? ActiveRecord::Base # edit_resource_url(@post)
84
+ # opt.merge!(options) if options.class==Hash
85
+ # opt[:action] ||= 'show'
86
+ # opt[:id] ||= resource.id
87
+ # opt[:controller] ||= resource_class.table_name
88
+ # url_for opt
89
+ end
90
+
91
+ def resource_options options={}
92
+ options.merge! params.except( "id", "controller", "action", "utf8", "_method", "authenticity_token" )
93
+ options.empty? ? "" : "?" + options.collect{ |k,v| "#{k}=#{v}" }.join("&")
80
94
  end
81
95
 
82
96
  #
@@ -93,8 +107,12 @@ module AbstractResourcesHelper
93
107
  # edit_resource_url returns the current entity's url for editing
94
108
  def edit_resource_url(options={})
95
109
  opt = {}
96
- opt[:id] = options.id if options.class.ancestors.include? ActiveRecord::Base # edit_resource_url(@post)
97
- opt.merge!(options) if options.class==Hash
110
+ if options.class.ancestors.include? ActiveRecord::Base # edit_resource_url(@post)
111
+ return '' if options.id.nil? # raise "'id' value nil - cannot build edit_resource_url"
112
+ opt[:id] = options.id
113
+ else
114
+ opt.merge!(options) if options.class==Hash
115
+ end
98
116
  opt[:action] = :edit
99
117
  resource_url opt
100
118
  # opt[:id] ||= @resource.id
@@ -34,7 +34,6 @@ LISTEND
34
34
  lst = []
35
35
  # if items are empty - dream them up
36
36
  options[:items] ||= {}
37
-
38
37
  options[:items].merge!( list: { ajax: 'get', icon: 'list', class: 'blue', url: resources_url(resources, controller: params[:controller]), oxremote: 'false' }){ |key, v1, v2| v1 }
39
38
 
40
39
  case options[:action]
@@ -1,3 +1,3 @@
1
1
  module Abstracted
2
- VERSION = "0.4.16"
2
+ VERSION = "0.4.17"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: abstracted
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.16
4
+ version: 0.4.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Walther H Diechmann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-10 00:00:00.000000000 Z
11
+ date: 2017-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails