Module ResourceController::Helpers::Internal
In: ../lib/resource_controller/helpers/internal.rb

Methods

Protected Instance methods

Calls the after callbacks for the action, if one is present.

[Source]

    # File ../lib/resource_controller/helpers/internal.rb, line 25
25:         def after(action)
26:           invoke_callbacks *options_for(action).after
27:         end

Calls the before block for the action, if one is present.

[Source]

    # File ../lib/resource_controller/helpers/internal.rb, line 31
31:         def before(action)
32:           invoke_callbacks *self.class.send(action).before
33:         end

[Source]

    # File ../lib/resource_controller/helpers/internal.rb, line 70
70:         def invoke_callbacks(*callbacks)
71:           unless callbacks.empty?
72:             callbacks.select { |callback| callback.is_a? Symbol }.each { |symbol| send(symbol) }
73:     
74:             block = callbacks.detect { |callback| callback.is_a? Proc }
75:             instance_eval &block unless block.nil?
76:           end
77:         end

Returns the options for an action, which is a symbol.

Manages splitting things like :create_fails.

[Source]

    # File ../lib/resource_controller/helpers/internal.rb, line 62
62:         def options_for(action)
63:           action = action == :new_action ? [action] : "#{action}".split('_').map(&:to_sym)
64:           options = self.class.send(action.first)
65:           options = options.send(action.last == :fails ? :fails : :success) if ResourceController::FAILABLE_ACTIONS.include? action.first
66:   
67:           options
68:         end

Used to actually pass the responses along to the controller‘s respond_to method.

[Source]

    # File ../lib/resource_controller/helpers/internal.rb, line 11
11:         def response_for(action)
12:           respond_to do |wants|
13:             options_for(action).response.each do |method, block|
14:               if block.nil?
15:                 wants.send(method)
16:               else
17:                 wants.send(method) { instance_eval(&block) }
18:               end
19:             end
20:           end
21:         end

Sets the flash and flash_now for the action, if it is present.

[Source]

    # File ../lib/resource_controller/helpers/internal.rb, line 37
37:         def set_flash(action)
38:           set_normal_flash(action)
39:           set_flash_now(action)
40:         end

Sets the flash.now (i.e. flash.now[:notice] = ’…’)

[Source]

    # File ../lib/resource_controller/helpers/internal.rb, line 52
52:         def set_flash_now(action)
53:           if f = options_for(action).flash_now
54:             flash.now[:notice] = f.is_a?(Proc) ? instance_eval(&f) : options_for(action).flash_now
55:           end
56:         end

Sets the regular flash (i.e. flash[:notice] = ’…’)

[Source]

    # File ../lib/resource_controller/helpers/internal.rb, line 44
44:         def set_normal_flash(action)
45:           if f = options_for(action).flash
46:             flash[:notice]     = f.is_a?(Proc) ? instance_eval(&f) : options_for(action).flash
47:           end
48:         end

[Validate]