Method: Rango::MessageMixin.included
- Defined in:
- lib/rango/mixins/message.rb
.included(controller) ⇒ Object
The rails-style flash messages NOTE: it’s important to include this mixin after ImplicitRendering mixin
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/rango/mixins/message.rb', line 8 def self.included(controller) controller.class_eval do if self.method_defined?(:context) Rango.logger.debug("Extending #{self}#context by message") # This could be in the mixin itself, but we don't want # to define it if the context method doesn't exist, so # context.respond_to?(:context) as a detection of explicit # rendering mixin and similar can work. BTW the following # doesn't work with do/end syntax. include Module.new { def context @context ||= super.merge!(message: self.) end } else Rango.logger.warn("Context #{self}#method isn't defined") end end end |