aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorZog2018-01-22 09:54:20 +0100
committerZog2018-01-25 17:18:01 +0100
commitff5d96b530a41669c394b7b0dc138e29da48e97d (patch)
treecc731e14383ef8f47302478faebac493dadacdf8 /lib
parent872f9476971d3bde6e6f470153af09ed87af1b28 (diff)
downloadchouette-core-ff5d96b530a41669c394b7b0dc138e29da48e97d.tar.bz2
Refs #5586 @2h; Fix specs
Diffstat (limited to 'lib')
-rw-r--r--lib/af83/decorator.rb19
-rw-r--r--lib/af83/decorator/enhanced_decorator.rb (renamed from lib/af83/enhanced_decorator.rb)5
-rw-r--r--lib/af83/decorator/link.rb1
3 files changed, 10 insertions, 15 deletions
diff --git a/lib/af83/decorator.rb b/lib/af83/decorator.rb
index 53e09fed3..e83e03e0f 100644
--- a/lib/af83/decorator.rb
+++ b/lib/af83/decorator.rb
@@ -1,6 +1,6 @@
class AF83::Decorator < ModelDecorator
- include AF83::EnhancedDecorator
- extend AF83::EnhancedDecorator::ClassMethods
+ include AF83::Decorator::EnhancedDecorator
+ extend AF83::Decorator::EnhancedDecorator::ClassMethods
def self.decorates klass
instance_decorator.decorates klass
@@ -31,6 +31,8 @@ class AF83::Decorator < ModelDecorator
class ActionLinks
attr_reader :options
+ delegate :each, :map, :size, :first, :last, :any?, :select, to: :resolve
+
def initialize opts
@options = opts.deep_dup
end
@@ -66,6 +68,7 @@ class AF83::Decorator < ModelDecorator
end
out
end
+ alias_method :to_ary, :resolve
def grouped_by *groups
add_footer = groups.include?(:footer)
@@ -91,14 +94,6 @@ class AF83::Decorator < ModelDecorator
out
end
- alias_method :to_ary, :resolve
-
- %w(each map size first last any?).each do |meth|
- define_method meth do |*args, &block|
- resolve.send meth, *args, &block
- end
- end
-
private
def returning_a_copy &block
out = ActionLinks.new options
@@ -111,7 +106,7 @@ class AF83::Decorator < ModelDecorator
end
class InstanceDecorator < Draper::Decorator
- include AF83::EnhancedDecorator
- extend AF83::EnhancedDecorator::ClassMethods
+ include AF83::Decorator::EnhancedDecorator
+ extend AF83::Decorator::EnhancedDecorator::ClassMethods
end
end
diff --git a/lib/af83/enhanced_decorator.rb b/lib/af83/decorator/enhanced_decorator.rb
index aa9620dba..904d1b2da 100644
--- a/lib/af83/enhanced_decorator.rb
+++ b/lib/af83/decorator/enhanced_decorator.rb
@@ -1,4 +1,4 @@
-module AF83::EnhancedDecorator
+module AF83::Decorator::EnhancedDecorator
module ClassMethods
def action_link args={}
raise "You are using `action_link` inside a with_instance_decorator block, but not on the instance decorator itself.\n Use `instance_decorator.action_link` or move outside of the block, as this may lead to an unforeseen behaviour." if @_with_instance_decorator
@@ -33,6 +33,7 @@ module AF83::EnhancedDecorator
def show_action_link args={}, &block
opts = {
+ on: :index,
primary: :index,
before_block: -> (l){
l.content { h.t('actions.show') }
@@ -62,7 +63,7 @@ module AF83::EnhancedDecorator
before_block: -> (l){
l.content { h.destroy_link_content }
l.href { [object] }
- l.method { :delete }
+ l.method :delete
l.data {{ confirm: h.t('actions.destroy_confirm') }}
}
}
diff --git a/lib/af83/decorator/link.rb b/lib/af83/decorator/link.rb
index 83d40eba8..b1958532f 100644
--- a/lib/af83/decorator/link.rb
+++ b/lib/af83/decorator/link.rb
@@ -96,7 +96,6 @@ class AF83::Decorator::Link
enabled = enabled && check_policy(@options[:_policy]) if @options[:_policy].present?
enabled = enabled && check_feature(@options[:_feature]) if @options[:_feature].present?
-
enabled
end