Module: Layout::Base

Defined in:
lib/layout/base.rb

Defined Under Namespace

Modules: InstanceMethods

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/layout/base.rb', line 3

def self.included(base)
  base.class_eval do
    include InstanceMethods

    def self.layout_options
      @layout_options ||= []
    end

    def self.layout_options=(options)
      @layout_options = options
    end

    # Set current action's layout.
    # Works in the same old fashion, but you can have multiple calls to it.
    #
    #   set_layout :application
    #   set_layout :site, :only => %w[show edit]
    #   set_layout :site, :except => %w[remove index]
    #
    def self.set_layout(name, options = {})
      self.layout_options << [name.to_s, options]
      layout :choose_layout
    end
  end
end