class Controll::Notify::Flash
Attributes
types[W]
controller[R]
Public Class Methods
new(controller, options = {})
click to toggle source
# File lib/controll/notify/flash.rb, line 6 def initialize controller, options = {} @controller = controller @options = options if options.kind_of? Hash end
Protected Class Methods
add_types(*types)
click to toggle source
# File lib/controll/notify/flash.rb, line 26 def add_types *types @types += types if types.all? {|type| type.kind_of? Symbol} end
Also aliased as: add_type
types()
click to toggle source
# File lib/controll/notify/flash.rb, line 22 def types @types ||= Controll::Event.valid_types end
Protected Instance Methods
options()
click to toggle source
# File lib/controll/notify/flash.rb, line 13 def options @options ||= {} end
signal(msg, type = nil)
click to toggle source
# File lib/controll/notify/flash.rb, line 32 def signal msg, type = nil return if msg.blank? type ||= signal_type || :notice raise ArgumentError, "Unsupported flash type: #{type}. Register via #{self.class.name}#types or #add_type" unless valid_type? type flash[type] = msg unless type.blank? end
signal_type()
click to toggle source
# File lib/controll/notify/flash.rb, line 47 def signal_type self.class.signal_type end
types()
click to toggle source
# File lib/controll/notify/flash.rb, line 43 def types self.class.types.map(&:to_sym) end
valid_type?(type)
click to toggle source
# File lib/controll/notify/flash.rb, line 39 def valid_type? type types.include? type.to_sym end