effective_orders 1.4.5 → 1.4.6

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: b863396582c8b6dc004e50916344386322c721e4
4
- data.tar.gz: 75223e7cb0bec3465f05ccf74d388b7cdeb6e6b1
3
+ metadata.gz: 87ba5d572d9c6252280ef318455a3c9ad73cec07
4
+ data.tar.gz: ce7b5f6096fcb1f02954573d75241e4c23fd8fb8
5
5
  SHA512:
6
- metadata.gz: 8c85fe756ef8eee38e47278600a689b07725fdcaf265bd9aba1196109372fa6572c8eda940b03eb8c7df7e2493abd280a385b5d11791528689d61cc640491a3b
7
- data.tar.gz: 11589512f20e9617056ead5bb1a711f11cb776681c85d109a433d41c754e97d6ec06dfde2fc632fc6506c9d99c94f940a6ed9f24ffc482a692535bebd96252f5
6
+ metadata.gz: c15b40d769f37947efb3614deaeef1b7de514737e7e009ec6476dd0e46fc5c19e668013bf8d791dba0f6f7d1b309c93f2a55933ba3b1875c70d5b3df4de24025
7
+ data.tar.gz: cfbf07a9b769fbb4d667cbae1db3e61dc3e3b54d149f943bcfc1d920e1d7070f35c5ce2e2355a27e6e47971a2b7d8fce0ca69149a3405020cb55285e15d9b44a
@@ -0,0 +1,47 @@
1
+ module Effective
2
+ module ActiveAdminHelpers
3
+ module Carts
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ include ::ActiveAdmin::BaseController::Menu
8
+ include ::ActiveAdmin::BaseController::Authorization
9
+
10
+ helper ::ActiveAdmin::ViewHelpers
11
+ helper_method :active_admin_config, :active_admin_namespace, :current_active_admin_user
12
+ helper_method :resource, :resource_path
13
+ end
14
+
15
+ module ClassMethods
16
+ end
17
+
18
+ def resource
19
+ instance_variable_get(@cart)
20
+ end
21
+
22
+ def resource_path(resource)
23
+ effective_orders.cart_path
24
+ end
25
+
26
+ def active_admin_namespace
27
+ ::ActiveAdmin.application.namespaces[EffectiveOrders.active_admin_namespace || :root]
28
+ end
29
+
30
+ def active_admin_config
31
+ active_admin_namespace.resources[active_admin_resource_key]
32
+ end
33
+
34
+ def active_admin_resource_key
35
+ @active_admin_resource_key ||= begin
36
+ namespace = ::ActiveAdmin.application.namespaces[EffectiveOrders.active_admin_namespace || :root]
37
+ namespace.resources.keys.find { |resource| resource.element == 'carts' }
38
+ end
39
+ end
40
+
41
+ def current_active_admin_user
42
+ send(active_admin_namespace.current_user_method) if active_admin_namespace.current_user_method
43
+ end
44
+
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,47 @@
1
+ module Effective
2
+ module ActiveAdminHelpers
3
+ module Orders
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ include ::ActiveAdmin::BaseController::Menu
8
+ include ::ActiveAdmin::BaseController::Authorization
9
+
10
+ helper ::ActiveAdmin::ViewHelpers
11
+ helper_method :active_admin_config, :active_admin_namespace, :current_active_admin_user
12
+ helper_method :resource, :resource_path
13
+ end
14
+
15
+ module ClassMethods
16
+ end
17
+
18
+ def resource
19
+ instance_variable_get(@order)
20
+ end
21
+
22
+ def resource_path(resource)
23
+ effective_orders.order_path(resource)
24
+ end
25
+
26
+ def active_admin_namespace
27
+ ::ActiveAdmin.application.namespaces[EffectiveOrders.active_admin_namespace || :root]
28
+ end
29
+
30
+ def active_admin_config
31
+ active_admin_namespace.resources[active_admin_resource_key]
32
+ end
33
+
34
+ def active_admin_resource_key
35
+ @active_admin_resource_key ||= begin
36
+ namespace = ::ActiveAdmin.application.namespaces[EffectiveOrders.active_admin_namespace || :root]
37
+ namespace.resources.keys.find { |resource| resource.element == 'orders' }
38
+ end
39
+ end
40
+
41
+ def current_active_admin_user
42
+ send(active_admin_namespace.current_user_method) if active_admin_namespace.current_user_method
43
+ end
44
+
45
+ end
46
+ end
47
+ end
@@ -1,7 +1,8 @@
1
1
  module Effective
2
2
  class CartsController < ApplicationController
3
3
  include EffectiveCartsHelper
4
- acts_as_active_admin_controller('carts') if defined?(ActiveAdmin) && EffectiveOrders.use_active_admin == true
4
+ include ActiveAdminHelpers::Carts if EffectiveOrders.use_active_admin
5
+
5
6
  layout (EffectiveOrders.layout.kind_of?(Hash) ? EffectiveOrders.layout[:carts] : EffectiveOrders.layout)
6
7
 
7
8
  def show
@@ -1,7 +1,7 @@
1
1
  module Effective
2
2
  class OrdersController < ApplicationController
3
3
  include EffectiveCartsHelper
4
- acts_as_active_admin_controller('orders') if defined?(ActiveAdmin) && EffectiveOrders.use_active_admin == true
4
+ include ActiveAdminHelpers::Orders if EffectiveOrders.use_active_admin
5
5
 
6
6
  include Providers::Moneris if EffectiveOrders.moneris_enabled
7
7
  include Providers::Paypal if EffectiveOrders.paypal_enabled
@@ -43,9 +43,9 @@ module EffectiveOrders
43
43
  # ActiveAdmin (optional)
44
44
  # This prepends the load path so someone can override the assets.rb if they want.
45
45
  initializer 'effective_orders.active_admin' do
46
- if defined?(ActiveAdmin) && EffectiveOrders.use_active_admin == true
47
- ActionController::Base.extend(::ActsAsActiveAdminController::ActionController)
48
- ActiveAdmin.application.load_paths.unshift Dir["#{config.root}/active_admin"]
46
+ if EffectiveOrders.use_active_admin
47
+ require 'active_admin'
48
+ ::ActiveAdmin.application.load_paths.unshift Dir["#{config.root}/active_admin"]
49
49
  end
50
50
  end
51
51
 
@@ -1,3 +1,3 @@
1
1
  module EffectiveOrders
2
- VERSION = '1.4.5'.freeze
2
+ VERSION = '1.4.6'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_orders
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.5
4
+ version: 1.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
@@ -325,7 +325,8 @@ files:
325
325
  - app/controllers/admin/customers_controller.rb
326
326
  - app/controllers/admin/order_items_controller.rb
327
327
  - app/controllers/admin/orders_controller.rb
328
- - app/controllers/concerns/acts_as_active_admin_controller.rb
328
+ - app/controllers/effective/active_admin_helpers/carts.rb
329
+ - app/controllers/effective/active_admin_helpers/orders.rb
329
330
  - app/controllers/effective/carts_controller.rb
330
331
  - app/controllers/effective/orders_controller.rb
331
332
  - app/controllers/effective/providers/moneris.rb
@@ -1,60 +0,0 @@
1
- module ActsAsActiveAdminController
2
- extend ActiveSupport::Concern
3
-
4
- module ActionController
5
- def acts_as_active_admin_controller(key)
6
- puts "== acts_as_active_admin_controller(#{key})"
7
- @active_admin_resource_element_lookup_key = key
8
- include ::ActsAsActiveAdminController
9
- end
10
- end
11
-
12
- included do
13
- include ::ActiveAdmin::BaseController::Menu
14
- include ::ActiveAdmin::BaseController::Authorization
15
-
16
- helper ::ActiveAdmin::ViewHelpers
17
- helper_method :active_admin_config, :active_admin_namespace, :current_active_admin_user
18
-
19
- resource_key = @active_admin_resource_element_lookup_key.to_s
20
- self.send(:define_method, :active_admin_resource_element_key) { resource_key }
21
-
22
- resource_ivar = '@' + resource_key.singularize
23
- self.send(:define_method, :resource) { instance_variable_get(resource_ivar) }
24
-
25
- resource_path = "effective_orders.#{resource_key.singularize}_path"
26
-
27
- if resource_path == 'effective_orders.cart_path'
28
- self.send(:define_method, :resource_path) { |resource| effective_orders.cart_path }
29
- else
30
- self.send(:define_method, :resource_path) { |resource| public_send(resource_path, resource) }
31
- end
32
-
33
- helper_method :resource, :resource_path
34
-
35
- end
36
-
37
- module ClassMethods
38
- end
39
-
40
- def active_admin_namespace
41
- ActiveAdmin.application.namespaces[EffectiveOrders.active_admin_namespace || :root]
42
- end
43
-
44
- def active_admin_config
45
- active_admin_namespace.resources[active_admin_resource_key]
46
- end
47
-
48
- def active_admin_resource_key
49
- @active_admin_resource_key ||= begin
50
- namespace = ActiveAdmin.application.namespaces[EffectiveOrders.active_admin_namespace || :root]
51
- namespace.resources.keys.find { |resource| resource.element == active_admin_resource_element_key }
52
- end
53
- end
54
-
55
- def current_active_admin_user
56
- send(active_admin_namespace.current_user_method) if active_admin_namespace.current_user_method
57
- end
58
-
59
- end
60
-