Sha256: b87d9da76934f8fced7af5200e1ebf862a2b4fa97618431a1600cdebe1d99191

Contents?: true

Size: 863 Bytes

Versions: 1

Compression:

Stored size: 863 Bytes

Contents

module RocketIO
  class Controller

    # by default templates will be rendered without layout.
    # to make them render inside a layout use `layout :layout_name` at class level.
    # to use a layout it should be defined at first (@see define_layout)
    #
    # @note to disable layout set it to false: `layout false`
    #
    # @param layout  name of a defined layout
    #
    def self.layout layout
      @__layout__ = layout
      define_layout_methods
    end

    def self.define_layout_methods source = self
      return unless source.instance_variables.include?(:@__layout__)
      layout = source.instance_variable_get(:@__layout__)
      private_api << define_method(:layout) {layout}
    end

    # by default no layout used, so this method returns nil.
    # controllers that uses a layout will override this method.
    def layout; end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rocketio-0.1.0 lib/rocketio/controller/render/layout.rb