Module: Releaf::Responders

Included in:
ActionController
Defined in:
app/lib/releaf/responders.rb,
app/lib/releaf/responders/destroy_responder.rb,
app/lib/releaf/responders/after_save_responder.rb,
app/lib/releaf/responders/confirm_destroy_responder.rb

Defined Under Namespace

Classes: AfterSaveResponder, ConfirmDestroyResponder, DestroyResponder

Instance Method Summary collapse

Instance Method Details

#action_responder(name_of_action) ⇒ Object

Returns generic view name for given action

Returns:

  • String


19
20
21
# File 'app/lib/releaf/responders.rb', line 19

def action_responder(name_of_action)
  action_responders[name_of_action.to_sym]
end

#action_respondersObject


8
9
10
11
12
13
14
15
# File 'app/lib/releaf/responders.rb', line 8

def action_responders
  {
    create: Releaf::Responders::AfterSaveResponder,
    update: Releaf::Responders::AfterSaveResponder,
    confirm_destroy: Releaf::Responders::ConfirmDestroyResponder,
    destroy: Releaf::Responders::DestroyResponder,
  }
end

#active_responderObject

Returns generic view name for current action

Returns:

  • String


25
26
27
# File 'app/lib/releaf/responders.rb', line 25

def active_responder
  action_responder(action_name)
end

#respond_with(resource = nil, options = {}, &block) ⇒ Object


3
4
5
6
# File 'app/lib/releaf/responders.rb', line 3

def respond_with(resource = nil, options = {}, &block)
  options[:responder] = active_responder unless options.has_key? :responder
  super
end