Module: Exposure::Flashing::ClassMethods

Defined in:
lib/exposure/behaviors/flashing.rb

Instance Method Summary collapse

Instance Method Details

#flash_for(action_name, options = {}, &block) ⇒ Object

configure flash messages valid action names are

:index :show :new :create :edit :update :destroy

valid options are

:on (optional)
  :success, :failure, :any
  default is :any
:is (optional if block given)
  can be a Proc or method name as symbol.


18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/exposure/behaviors/flashing.rb', line 18

def flash_for(action_name, options = {}, &block)
  options[:is] ||= block
  
  case options[:on]
  when NilClass, :any
    self.const_get(:FlashMessages)["#{action_name}.success.html"]  = options[:is]
    self.const_get(:FlashMessages)["#{action_name}.failure.html"]  = options[:is]
  when :success
    self.const_get(:FlashMessages)["#{action_name}.success.html"]  = options[:is]
  when :failure
    self.const_get(:FlashMessages)["#{action_name}.failure.html"]  = options[:is]
  end
end