diff options
| author | Zog | 2018-01-16 16:51:58 +0100 |
|---|---|---|
| committer | Zog | 2018-01-25 17:17:59 +0100 |
| commit | 44d38ab6b6a05a56a73c443c62f4a88d1733f274 (patch) | |
| tree | 6f93498e6d2316d27590803598dfea728caa459f /lib | |
| parent | 04e6d933e2c140dbdd24e29a6139d74fab3c386d (diff) | |
| download | chouette-core-44d38ab6b6a05a56a73c443c62f4a88d1733f274.tar.bz2 | |
Refs #5586 @1h; Migrate TimeTableDecorator
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/af83/decorator.rb | 8 | ||||
| -rw-r--r-- | lib/af83/enhanced_decorator.rb | 1 |
2 files changed, 8 insertions, 1 deletions
diff --git a/lib/af83/decorator.rb b/lib/af83/decorator.rb index ec62edaaa..82954adc1 100644 --- a/lib/af83/decorator.rb +++ b/lib/af83/decorator.rb @@ -7,11 +7,17 @@ class AF83::Decorator < ModelDecorator end def self.instance_decorator - @instance_decorator ||= Class.new(AF83::Decorator::InstanceDecorator) + @instance_decorator ||= begin + klass = Class.new(AF83::Decorator::InstanceDecorator) + klass.delegate_all + klass + end end def self.with_instance_decorator + @_with_instance_decorator = true yield instance_decorator + @_with_instance_decorator = false end def self.decorate object, options = {} diff --git a/lib/af83/enhanced_decorator.rb b/lib/af83/enhanced_decorator.rb index ad9a75000..91a377f8c 100644 --- a/lib/af83/enhanced_decorator.rb +++ b/lib/af83/enhanced_decorator.rb @@ -1,6 +1,7 @@ module AF83::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 args[:if] = @_condition if args[:if].nil? options, link_options = parse_options args |
