Module: ActionController::Layout

Defined in:
lib/action_controller/layout.rb

Overview

:nodoc:

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



3
4
5
6
7
8
9
10
# File 'lib/action_controller/layout.rb', line 3

def self.included(base)
  base.extend(ClassMethods)
  base.class_eval do
    class << self
      alias_method_chain :inherited, :layout
    end
  end
end

Instance Method Details

#active_layout(passed_layout = nil, options = {}) ⇒ Object

Returns the name of the active layout. If the layout was specified as a method reference (through a symbol), this method is called and the return value is used. Likewise if the layout was specified as an inline method (through a proc or method object). If the layout was defined without a directory, layouts is assumed. So layout "weblog/standard" will return weblog/standard, but layout "standard" will return layouts/standard.



206
207
208
209
210
211
212
213
214
215
216
217
# File 'lib/action_controller/layout.rb', line 206

def active_layout(passed_layout = nil, options = {})
  layout = passed_layout || default_layout
  return layout if layout.respond_to?(:render)

  active_layout = case layout
    when Symbol then __send__(layout)
    when Proc   then layout.call(self)
    else layout
  end

  find_layout(active_layout, default_template_format, options[:html_fallback]) if active_layout
end

#initialize(*args) ⇒ Object



197
198
199
200
# File 'lib/action_controller/layout.rb', line 197

def initialize(*args)
  super
  @real_format = nil
end