Module: RespondForHelper::Controller

Extended by:
ActiveSupport::Concern
Defined in:
lib/respond_for_helper/controller.rb

Instance Method Summary collapse

Instance Method Details

#respond_for(item, options = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/respond_for_helper/controller.rb', line 7

def respond_for(item, options = {})
  respond = Respond.new(self, item, options)
  respond_to do |format|
    yield(format, respond) if block_given?
    respond.formatters.each do |formatter|
      format.send(formatter.format) { formatter.call }
    end
    respond.run_before_callbacks
  end
  respond.run_after_callbacks
end

#respond_for_message(type, options = {}) ⇒ Object



19
20
21
22
23
# File 'lib/respond_for_helper/controller.rb', line 19

def respond_for_message(type, options = {})
  klass = Lookups::Flash.new(self, options).call
  options = options.reverse_merge(controller_path: controller_path, action_name: action_name)
  klass.new(type, options).call
end