effective_resources 1.4.12 → 1.5.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
  SHA256:
3
- metadata.gz: 257e008e3128f7406e1326a914150fff64ef02bd5fd066eaa5f0eae4dda85504
4
- data.tar.gz: 395118768affb307c80e80ee94b2a07396400697986b4a4a9e582336460b9057
3
+ metadata.gz: e01b50384fc2d41b95913769c539276b592257b4f36109917a02afe5a74a8584
4
+ data.tar.gz: 005a5676dca6e1d0e14a19ad96f31d834a85fdec527514bc75b86d040b3ed2f0
5
5
  SHA512:
6
- metadata.gz: 9bdd4a65ca14b8c0e92f312d6d4ad7e49f1fd4966608dd01afb49a637b2f075e6ff92d740148c609ae6239709f786bf5d75fffd7a6292aef5ea60388fcd3c035
7
- data.tar.gz: 8e2099089a87a6833f0e1041f85ea8b91954de940ce63433197f8372cf18901d2e8ee6a384529acca2568d5c99b9a2bf7b50713c573e219477055c2707e46153
6
+ metadata.gz: 0d135e3a5f848c0ee8f40d89e5412a4576fdd4e25068cd5df6ee3d01d3901db36f10c034376dc9bc253cc0f7aebbdce242cebca9c988e8a2bb315621aee80f80
7
+ data.tar.gz: c7808cfa20c0b8c7b256a0dc5d46ba0b39bf6c638d1200820cd93c50228b8c456b77f9adbe34039825c6e0a00dc5312b6da4ab51a464769ac8b11f91393dcd78
@@ -63,9 +63,11 @@ module Effective
63
63
  self.resource ||= resource_scope.new
64
64
  action = (commit_action[:action] == :save ? :create : commit_action[:action])
65
65
 
66
- resource.assign_attributes(send(resource_params_method_name))
66
+ resource.current_user ||= current_user if resource.respond_to?(:current_user=)
67
67
  resource.created_by ||= current_user if resource.respond_to?(:created_by=)
68
68
 
69
+ resource.assign_attributes(send(resource_params_method_name))
70
+
69
71
  EffectiveResources.authorize!(self, action, resource)
70
72
  @page_title ||= "New #{resource_name.titleize}"
71
73
 
@@ -119,6 +121,9 @@ module Effective
119
121
  EffectiveResources.authorize!(self, action, resource)
120
122
  @page_title ||= "Edit #{resource}"
121
123
 
124
+ resource.current_user ||= current_user if resource.respond_to?(:current_user=)
125
+ resource.updated_by ||= current_user if resource.respond_to?(:updated_by=)
126
+
122
127
  resource.assign_attributes(send(resource_params_method_name))
123
128
 
124
129
  if save_resource(resource, action)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module EffectiveResourcesHelper
2
4
 
3
5
  # effective_bootstrap
@@ -74,18 +76,22 @@ module EffectiveResourcesHelper
74
76
  namespace ||= (effective_resource.namespace.to_sym if effective_resource.namespace)
75
77
 
76
78
  # Assign actions
77
- actions = if atts.key?(:actions) # We filter out any actions passed to us that aren't supported
78
- available = effective_resource.actions + atts[:actions].map { |k, v| v[:action] if v[:path] }.compact
79
- atts[:actions].inject({}) { |h, (commit, opts)| h[commit] = opts if available.include?(opts[:action]); h }
79
+ # We filter out any actions passed to us that aren't supported
80
+ actions = if atts.key?(:actions)
81
+ {}.tap do |actions|
82
+ atts[:actions].each do |commit, opts|
83
+ actions[commit] = opts if (effective_resource.actions.include?(opts[:action]) || opts[:path]).present?
84
+ end
85
+ end
80
86
  else
81
87
  (resource.kind_of?(Class) ? effective_resource.resource_klass_actions : effective_resource.resource_actions)
82
88
  end
83
89
 
84
90
  # Consider only, except, false and proc false
85
- only = Array(atts[:only]).compact
86
- except = Array(atts[:except]).compact
91
+ only = Array(atts[:only]) if atts[:only].present?
92
+ except = Array(atts[:except]) if atts[:except].present?
87
93
 
88
- actions = actions.select do |_, opts|
94
+ actions.select! do |_, opts|
89
95
  action = opts[:action]
90
96
 
91
97
  if only.present? && !only.include?(action)
@@ -100,8 +106,11 @@ module EffectiveResourcesHelper
100
106
  end
101
107
 
102
108
  # Select Partial
103
- partial = ['effective/resource/actions', partial.to_s].join('_') if partial.kind_of?(Symbol)
104
- partial = (partial.presence || 'effective/resource/actions') + '.html'
109
+ partial = if partial.kind_of?(Symbol)
110
+ "effective/resource/actions_#{partial}.html"
111
+ else
112
+ "#{partial.presence || 'effective/resource/actions'}.html"
113
+ end
105
114
 
106
115
  # Assign Locals
107
116
  locals = {
@@ -2,21 +2,27 @@
2
2
 
3
3
  module EffectiveResourcesPrivateHelper
4
4
  REPLACE_PAGE_ACTIONS = {'update' => :edit, 'create' => :new}
5
+ BLACKLIST = [:default, :only, :except, :if, :unless, :redirect, :success, :danger, :klass]
6
+
7
+ DATA_CONFIRM = 'data-confirm'
5
8
 
6
9
  def permitted_resource_actions(resource, actions)
7
10
  page_action = REPLACE_PAGE_ACTIONS[params[:action]] || params[:action].try(:to_sym) || :save
8
11
  executor = Effective::ResourceExec.new(self, resource)
9
12
 
10
- actions.select do |commit, args|
13
+ actions.each_with_object({}) do |(commit, args), h|
11
14
  action = (args[:action] == :save ? (resource.new_record? ? :create : :update) : args[:action])
12
15
 
13
- (args.key?(:only) ? args[:only].include?(page_action) : true) &&
14
- (args.key?(:except) ? !args[:except].include?(page_action) : true) &&
15
- (args.key?(:if) ? executor.instance_exec(&args[:if]) : true) &&
16
- (args.key?(:unless) ? !executor.instance_exec(&args[:unless]) : true) &&
17
- EffectiveResources.authorized?(controller, action, resource)
18
- end.inject({}) do |h, (commit, args)|
16
+ permitted = (args.key?(:only) ? args[:only].include?(page_action) : true) &&
17
+ (args.key?(:except) ? !args[:except].include?(page_action) : true) &&
18
+ (args.key?(:if) ? executor.instance_exec(&args[:if]) : true) &&
19
+ (args.key?(:unless) ? !executor.instance_exec(&args[:unless]) : true) &&
20
+ EffectiveResources.authorized?(controller, action, resource)
21
+
22
+ next unless permitted
23
+
19
24
  opts = args.except(:default, :only, :except, :if, :unless, :redirect, :success, :danger, :klass)
25
+ resource_to_s = resource.to_s.presence || resource.class.name.underscore
20
26
 
21
27
  # Transform data: { ... } hash into 'data-' keys
22
28
  if opts.key?(:data)
@@ -32,34 +38,34 @@ module EffectiveResourcesPrivateHelper
32
38
  end
33
39
 
34
40
  # Replace resource name in any token strings
35
- if opts.key?('data-confirm')
36
- opts['data-confirm'] = opts['data-confirm'].gsub('@resource', (resource.to_s.presence || resource.class.name.gsub('::', ' ').underscore.gsub('_', ' ')).to_s)
41
+ if opts[DATA_CONFIRM].present? && opts[DATA_CONFIRM].include?('@resource'.freeze)
42
+ opts[DATA_CONFIRM] = opts[DATA_CONFIRM].gsub('@resource'.freeze, resource_to_s)
37
43
  end
38
44
 
39
45
  # Assign class
40
46
  opts[:class] ||= (
41
- if opts['data-method'].to_s == 'delete'
42
- 'btn btn-danger'
47
+ if opts['data-method'.freeze] == 'delete'.freeze
48
+ 'btn btn-danger'.freeze
43
49
  elsif h.length == 0
44
- 'btn btn-primary'
50
+ 'btn btn-primary'.freeze
45
51
  elsif defined?(EffectiveBootstrap)
46
- 'btn btn-secondary'
52
+ 'btn btn-secondary'.freeze
47
53
  else
48
- 'btn btn-default'
54
+ 'btn btn-default'.freeze
49
55
  end
50
56
  )
51
57
 
52
58
  # Assign title
53
59
  opts[:title] ||= case opts[:action]
54
60
  when :save then commit
55
- when :edit then "Edit #{resource}"
56
- when :show then "#{resource}"
57
- when :destroy then "Delete #{resource}"
61
+ when :edit then "Edit #{resource_to_s}"
62
+ when :show then "#{resource_to_s}"
63
+ when :destroy then "Delete #{resource_to_s}"
58
64
  when :index then "All #{resource.class.name.gsub('::', ' ').underscore.gsub('_', ' ').titleize.pluralize}"
59
- else "#{opts[:action].to_s.titleize} #{resource}"
65
+ else "#{opts[:action].to_s.titleize} #{resource_to_s}"
60
66
  end
61
67
 
62
- h[commit] = opts; h
68
+ h[commit] = opts
63
69
  end
64
70
  end
65
71
 
@@ -51,4 +51,3 @@ module ActsAsTokened
51
51
  end
52
52
 
53
53
  end
54
-
@@ -44,6 +44,7 @@ module Effective
44
44
  when :string ; :string
45
45
  when :text ; :string
46
46
  when :time ; :time
47
+ when :uuid ; :uuid
47
48
  when FalseClass ; :boolean
48
49
  when (defined?(Integer) ? Integer : Fixnum) ; :integer
49
50
  when Float ; :decimal
@@ -75,11 +76,11 @@ module Effective
75
76
  when :date, :datetime
76
77
  if (digits = value.to_s.scan(/(\d+)/).flatten).present?
77
78
  date = if digits.first.length == 4 # 2017-01-10
78
- Time.zone.local(*digits)
79
+ (Time.zone.local(*digits) rescue nil)
79
80
  else # 01/10/2016
80
81
  year = digits.find { |d| d.length == 4}
81
82
  digits = [year] + (digits - [year])
82
- Time.zone.local(*digits)
83
+ (Time.zone.local(*digits) rescue nil)
83
84
  end
84
85
 
85
86
  name.to_s.start_with?('end_') ? date.end_of_day : date
@@ -87,7 +88,7 @@ module Effective
87
88
  when :time
88
89
  if (digits = value.to_s.scan(/(\d+)/).flatten).present?
89
90
  now = Time.zone.now
90
- Time.zone.local(now.year, now.month, now.day, *digits)
91
+ (Time.zone.local(now.year, now.month, now.day, *digits) rescue nil)
91
92
  end
92
93
  when :decimal, :currency
93
94
  (value.kind_of?(String) ? value.gsub(/[^0-9|\-|\.]/, '') : value).to_f
@@ -139,6 +140,8 @@ module Effective
139
140
  value.to_s
140
141
  end
141
142
  end
143
+ when :uuid
144
+ value.to_s
142
145
  when :active_storage
143
146
  value.to_s
144
147
  else
@@ -1,6 +1,9 @@
1
1
  module Effective
2
2
  class ModelReader
3
- DATATYPES = [:binary, :boolean, :date, :datetime, :decimal, :float, :hstore, :inet, :integer, :string, :text, :permitted_param]
3
+ DATATYPES = [
4
+ :binary, :boolean, :date, :datetime, :decimal, :float, :hstore, :inet, :integer,
5
+ :string, :text, :uuid, :permitted_param
6
+ ]
4
7
 
5
8
  attr_reader :attributes
6
9
 
@@ -1,12 +1,17 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Effective
2
4
  module Resources
3
5
  module Actions
6
+ EMPTY_HASH = {}
7
+ POST_VERBS = ['POST', 'PUT', 'PATCH']
8
+ CRUD_ACTIONS = %i(index new create show edit update destroy)
4
9
 
5
10
  # This was written for the Edit actions fallback templates and Datatables
6
11
  # Effective::Resource.new('admin/posts').routes[:index]
7
12
  def routes
8
13
  @routes ||= (
9
- matches = [[namespace, plural_name].compact.join('/'.freeze), [namespace, name].compact.join('/'.freeze)]
14
+ matches = [[namespace, plural_name].compact.join('/'), [namespace, name].compact.join('/')]
10
15
 
11
16
  routes_engine.routes.routes.select do |route|
12
17
  matches.any? { |match| match == route.defaults[:controller] } && !route.name.to_s.end_with?('root')
@@ -19,7 +24,7 @@ module Effective
19
24
  # Effective::Resource.new('effective/order', namespace: :admin)
20
25
  def routes_engine
21
26
  case class_name
22
- when 'Effective::Order'.freeze
27
+ when 'Effective::Order'
23
28
  EffectiveOrders::Engine
24
29
  else
25
30
  Rails.application
@@ -30,12 +35,14 @@ module Effective
30
35
  # This will return empty for create, update and destroy
31
36
  def action_path_helper(action)
32
37
  return unless routes[action]
33
- return (routes[action].name + '_path'.freeze) if routes[action].name.present?
38
+ return (routes[action].name + '_path') if routes[action].name.present?
34
39
  end
35
40
 
36
41
  # Effective::Resource.new('admin/posts').action_path(:edit, Post.last) => '/admin/posts/3/edit'
37
42
  # Will work for any action. Returns the real path
38
- def action_path(action, resource = nil, opts = {})
43
+ def action_path(action, resource = nil, opts = nil)
44
+ opts ||= EMPTY_HASH
45
+
39
46
  if klass.nil? && resource.present? && initialized_name.kind_of?(ActiveRecord::Reflection::BelongsToReflection)
40
47
  return Effective::Resource.new(resource, namespace: namespace).action_path(action, resource, opts)
41
48
  end
@@ -53,12 +60,26 @@ module Effective
53
60
  end
54
61
  end
55
62
 
56
- # This generates the correct route when an object is overriding to_param
57
- if (resource || instance).respond_to?(:attributes)
58
- formattable = (resource || instance).attributes.symbolize_keys.merge(id: (resource || instance).to_param)
63
+ target = (resource || instance)
64
+
65
+ formattable = if routes[action].parts.include?(:id)
66
+ if target.respond_to?(:to_param) && target.respond_to?(:id) && (target.to_param != target.id.to_s)
67
+ routes[action].parts.each_with_object({}) do |part, h|
68
+ if part == :id
69
+ h[part] = target.to_param
70
+ elsif part == :format
71
+ # Nothing
72
+ elsif target.respond_to?(part)
73
+ h[part] = target.public_send(part)
74
+ end
75
+ end
76
+ else
77
+ target
78
+ end
59
79
  end
60
80
 
61
- path = routes[action].format(formattable || {}).presence
81
+ # Generate the path
82
+ path = routes[action].format(formattable || EMPTY_HASH)
62
83
 
63
84
  if path.present? && opts.present?
64
85
  uri = URI.parse(path)
@@ -70,74 +91,85 @@ module Effective
70
91
  end
71
92
 
72
93
  def actions
73
- routes.keys
94
+ @route_actions ||= routes.keys
74
95
  end
75
96
 
76
97
  def crud_actions
77
- actions & %i(index new create show edit update destroy)
98
+ @crud_actions ||= (actions & CRUD_ACTIONS)
78
99
  end
79
100
 
80
101
  # GET actions
81
102
  def collection_actions
82
- routes.values.map { |route| route.defaults[:action].to_sym if is_collection_route?(route) }.compact
103
+ @collection_actions ||= (
104
+ routes.map { |_, route| route.defaults[:action].to_sym if is_collection_route?(route) }.tap(&:compact!)
105
+ )
83
106
  end
84
107
 
85
108
  def collection_get_actions
86
- routes.values.map { |route| route.defaults[:action].to_sym if is_collection_route?(route) && is_get_route?(route) }.compact
109
+ @collection_get_actions ||= (
110
+ routes.map { |_, route| route.defaults[:action].to_sym if is_collection_route?(route) && is_get_route?(route) }.tap(&:compact!)
111
+ )
87
112
  end
88
113
 
89
114
  def collection_post_actions
90
- routes.values.map { |route| route.defaults[:action].to_sym if is_collection_route?(route) && is_post_route?(route) }.compact
115
+ @collection_post_actions ||= (
116
+ routes.map { |_, route| route.defaults[:action].to_sym if is_collection_route?(route) && is_post_route?(route) }.tap(&:compact!)
117
+ )
91
118
  end
92
119
 
93
120
  # All actions
94
121
  def member_actions
95
- routes.values.map { |route| route.defaults[:action].to_sym if is_member_route?(route) }.compact
122
+ @member_actions ||= (
123
+ routes.map { |_, route| route.defaults[:action].to_sym if is_member_route?(route) }.tap(&:compact!)
124
+ )
96
125
  end
97
126
 
98
127
  # GET actions
99
128
  def member_get_actions
100
- routes.values.map { |route| route.defaults[:action].to_sym if is_member_route?(route) && is_get_route?(route) }.compact
129
+ @member_get_actions ||= (
130
+ routes.map { |_, route| route.defaults[:action].to_sym if is_member_route?(route) && is_get_route?(route) }.tap(&:compact!)
131
+ )
101
132
  end
102
133
 
103
134
  def member_delete_actions
104
- routes.values.map { |route| route.defaults[:action].to_sym if is_member_route?(route) && is_delete_route?(route) }.compact
135
+ @member_delete_actions ||= (
136
+ routes.map { |_, route| route.defaults[:action].to_sym if is_member_route?(route) && is_delete_route?(route) }.tap(&:compact!)
137
+ )
105
138
  end
106
139
 
107
140
  # POST/PUT/PATCH actions
108
141
  def member_post_actions
109
- routes.values.map { |route| route.defaults[:action].to_sym if is_member_route?(route) && is_post_route?(route) }.compact
142
+ @member_post_actions ||= (
143
+ routes.map { |_, route| route.defaults[:action].to_sym if is_member_route?(route) && is_post_route?(route) }.tap(&:compact!)
144
+ )
110
145
  end
111
146
 
112
147
  # Same as controller_path in the view
113
148
  def controller_path
114
- [namespace, plural_name].compact * '/'.freeze
149
+ [namespace, plural_name].compact * '/'
115
150
  end
116
151
 
117
152
  private
118
153
 
119
154
  def is_member_route?(route)
120
- (route.path.required_names || []).include?('id'.freeze)
155
+ (route.path.required_names || []).include?('id')
121
156
  end
122
157
 
123
158
  def is_collection_route?(route)
124
- (route.path.required_names || []).include?('id'.freeze) == false
159
+ (route.path.required_names || []).include?('id') == false
125
160
  end
126
161
 
127
162
  def is_get_route?(route)
128
- route.verb.to_s.include?('GET'.freeze)
163
+ route.verb == 'GET'
129
164
  end
130
165
 
131
166
  def is_delete_route?(route)
132
- route.verb.to_s.include?('DELETE'.freeze)
167
+ route.verb == 'DELETE'
133
168
  end
134
169
 
135
170
  def is_post_route?(route)
136
- ['POST', 'PUT', 'PATCH'].freeze.any? { |verb| route.verb == verb }
171
+ POST_VERBS.include?(route.verb)
137
172
  end
138
173
  end
139
174
  end
140
175
  end
141
-
142
-
143
-
@@ -26,7 +26,10 @@ module Effective
26
26
 
27
27
  def has_ones
28
28
  return [] unless klass.respond_to?(:reflect_on_all_associations)
29
- klass.reflect_on_all_associations(:has_one).reject { |ass| ass.class_name.to_s.start_with?('ActiveStorage::') }
29
+
30
+ blacklist = ['ActiveStorage::', 'ActionText::']
31
+
32
+ klass.reflect_on_all_associations(:has_one).reject { |ass| blacklist.any? { |val| ass.class_name.start_with?(val) } }
30
33
  end
31
34
 
32
35
  def has_ones_ids
@@ -66,6 +69,14 @@ module Effective
66
69
  active_storage_has_ones.map { |ass| ass.name.to_s.gsub(/_attachment\z/, '').to_sym }
67
70
  end
68
71
 
72
+ def active_texts
73
+ klass.reflect_on_all_associations(:has_one).select { |ass| ass.class_name == 'ActionText::RichText' }
74
+ end
75
+
76
+ def active_texts_has_ones_ids
77
+ active_texts.map { |ass| ass.name.to_s.gsub(/\Arich_text_/, '').to_sym }
78
+ end
79
+
69
80
  def nested_resources
70
81
  return [] unless klass.respond_to?(:reflect_on_all_associations)
71
82
  klass.reflect_on_all_associations(:has_many).select { |ass| ass.options[:autosave] } +
@@ -153,7 +164,3 @@ module Effective
153
164
  end
154
165
  end
155
166
  end
156
-
157
-
158
-
159
-
@@ -52,6 +52,12 @@ module Effective
52
52
  end
53
53
  end
54
54
 
55
+ def active_text_attributes
56
+ {}.tap do |retval|
57
+ active_texts_has_ones_ids.each { |k, v| retval[k] = [:string] }
58
+ end
59
+ end
60
+
55
61
  # All will include primary_key, created_at, updated_at and belongs_tos
56
62
  # This is the attributes as defined by the effective_resources do .. end block
57
63
  # { :name => [:string, { permitted: false }], ... }
@@ -66,6 +72,7 @@ module Effective
66
72
  .merge(effective_addresses_attributes)
67
73
  .merge(effective_assets_attributes)
68
74
  .merge(active_storage_attributes)
75
+ .merge(active_text_attributes)
69
76
  .merge(atts)
70
77
  else # This is the migrator. This should match table_attributes
71
78
  belong_tos_attributes.merge(atts.reject { |_, v| v[0] == :permitted_param })
@@ -137,7 +144,3 @@ module Effective
137
144
  end
138
145
  end
139
146
  end
140
-
141
-
142
-
143
-
@@ -1,3 +1,5 @@
1
+ # frozen_sting_literals: true
2
+
1
3
  module Effective
2
4
  module Resources
3
5
  module Controller
@@ -66,15 +68,19 @@ module Effective
66
68
  # It is used by datatables
67
69
  def resource_actions
68
70
  {}.tap do |actions|
69
- (member_get_actions & crud_actions).reverse_each do |action|
71
+ member_get_actions.reverse_each do |action|
72
+ next unless crud_actions.include?(action)
70
73
  actions[action.to_s.titleize] = { action: action, default: true }
71
74
  end
72
75
 
73
- (member_get_actions - crud_actions).each do |action|
76
+ member_get_actions.each do |action|
77
+ next if crud_actions.include?(action)
74
78
  actions[action.to_s.titleize] = { action: action, default: true }
75
79
  end
76
80
 
77
- (member_post_actions - crud_actions).each do |action|
81
+ member_post_actions.each do |action|
82
+ next if crud_actions.include?(action)
83
+
78
84
  actions[action.to_s.titleize] = { action: action, default: true, 'data-method' => :post, 'data-confirm' => "Really #{action} @resource?" }
79
85
 
80
86
  actions[action.to_s.titleize] = case action
@@ -89,7 +95,7 @@ module Effective
89
95
 
90
96
  member_delete_actions.each do |action|
91
97
  if action == :destroy
92
- next if actions.values.find { |v| v[:action] == :archive }.present?
98
+ next if actions.find { |_, v| v[:action] == :archive }.present?
93
99
  actions['Delete'] = { action: action, default: true, 'data-method' => :delete, 'data-confirm' => "Really delete @resource?" }
94
100
  else
95
101
  actions[action.to_s.titleize] = { action: action, default: true, 'data-method' => :delete, 'data-confirm' => "Really #{action} @resource?" }
@@ -158,6 +158,12 @@ module Effective
158
158
  else
159
159
  relation.where("#{sql_column} = ?", term)
160
160
  end
161
+ when :uuid
162
+ if fuzzy
163
+ relation.where("#{sql_column}::text #{ilike} ?", "%#{term}%")
164
+ else
165
+ relation.where("#{sql_column}::text = ?", term)
166
+ end
161
167
  else
162
168
  raise "unsupported sql type #{sql_type}"
163
169
  end
@@ -1,5 +1,6 @@
1
1
  - permitted_resource_actions(resource, actions).each do |label, opts|
2
- = link_to(label, (effective_resource.action_path(opts[:action], resource) || '#'), opts.except(:action))
2
+ - action = opts.delete(:action)
3
+ = link_to(label, (effective_resource.action_path(action, resource) || '#'), opts)
3
4
 
4
5
  = instance_exec(resource, &format_block) if local_assigns[:format_block]
5
6
  = yield if block_given?
@@ -1,6 +1,9 @@
1
1
  = dropdown(variation: :dropleft, btn_class: btn_class) do
2
2
  - permitted_resource_actions(resource, actions).each do |label, opts|
3
- = dropdown_link_to(label, (effective_resource.action_path(opts[:action], resource) || '#'), opts.except(:action, :class).merge(btn_class: btn_class))
3
+ - action = opts.delete(:action)
4
+ - opts.delete(:class)
5
+
6
+ = dropdown_link_to(label, (effective_resource.action_path(action, resource) || '#'), opts)
4
7
 
5
8
  = instance_exec(resource, &format_block) if local_assigns[:format_block]
6
9
  = yield(resource) if block_given?
@@ -1,5 +1,8 @@
1
1
  - permitted_resource_actions(resource, actions).each do |label, opts|
2
- = glyphicon_to(opts[:action], (effective_resource.action_path(opts[:action], resource) || '#'), opts.except(:action, :class))
2
+ - action = opts.delete(:action)
3
+ - opts.delete(:class)
4
+
5
+ = glyphicon_to(action, (effective_resource.action_path(action, resource) || '#'), opts)
3
6
 
4
7
  = instance_exec(resource, &format_block) if local_assigns[:format_block]
5
8
  = yield(resource) if block_given?
@@ -1,5 +1,4 @@
1
1
  require 'effective_resources/engine'
2
- require 'effective_resources/version'
3
2
 
4
3
  module EffectiveResources
5
4
 
@@ -3,9 +3,14 @@ module EffectiveResources
3
3
  engine_name 'effective_resources'
4
4
 
5
5
  config.autoload_paths += Dir[
6
- "#{config.root}/lib/",
7
6
  "#{config.root}/jobs/",
8
- "#{config.root}/app/models/validators/",
7
+ "#{config.root}/lib/validators/",
8
+ "#{config.root}/app/controllers/concerns/"
9
+ ]
10
+
11
+ config.eager_load_paths += Dir[
12
+ "#{config.root}/jobs/",
13
+ "#{config.root}/lib/validators/",
9
14
  "#{config.root}/app/controllers/concerns/"
10
15
  ]
11
16
 
@@ -1,3 +1,3 @@
1
1
  module EffectiveResources
2
- VERSION = '1.4.12'.freeze
2
+ VERSION = '1.5.3'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_resources
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.12
4
+ version: 1.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-21 00:00:00.000000000 Z
11
+ date: 2020-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -71,9 +71,6 @@ files:
71
71
  - app/models/effective/resources/paths.rb
72
72
  - app/models/effective/resources/relation.rb
73
73
  - app/models/effective/resources/sql.rb
74
- - app/models/validators/email_cc_validator.rb
75
- - app/models/validators/email_validator.rb
76
- - app/models/validators/url_validator.rb
77
74
  - app/views/application/_flash.html.haml
78
75
  - app/views/application/create.js.erb
79
76
  - app/views/application/destroy.js.erb
@@ -94,11 +91,14 @@ files:
94
91
  - lib/effective_resources/engine.rb
95
92
  - lib/effective_resources/version.rb
96
93
  - lib/generators/effective_resources/install_generator.rb
94
+ - lib/validators/email_cc_validator.rb
95
+ - lib/validators/email_validator.rb
96
+ - lib/validators/url_validator.rb
97
97
  homepage: https://github.com/code-and-effect/effective_resources
98
98
  licenses:
99
99
  - MIT
100
100
  metadata: {}
101
- post_install_message:
101
+ post_install_message:
102
102
  rdoc_options: []
103
103
  require_paths:
104
104
  - lib
@@ -113,8 +113,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
113
  - !ruby/object:Gem::Version
114
114
  version: '0'
115
115
  requirements: []
116
- rubygems_version: 3.0.3
117
- signing_key:
116
+ rubygems_version: 3.1.4
117
+ signing_key:
118
118
  specification_version: 4
119
119
  summary: Make any controller an effective resource controller.
120
120
  test_files: []