Sha256: 9b308fb52a8e34c5bcdd7e469b697b83e96c2e21191dc8f6288d3b66851eacab

Contents?: true

Size: 562 Bytes

Versions: 10

Compression:

Stored size: 562 Bytes

Contents

module Nanoc

  # Nanoc::LayoutProxy is a proxy object for a layout (Nanoc::Layout).
  class LayoutProxy < Proxy

    # Requests the layout attribute with the given name. +key+ can be a string
    # or a symbol, and it can contain a trailing question mark (which will be
    # stripped).
    def [](key)
      real_key = key.to_s.sub(/\?$/, '').to_sym

      if real_key == :content
        @obj.content
      elsif real_key == :path
        @obj.path
      elsif real_key == :mtime
        @obj.mtime
      else
        super(key)
      end
    end

  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
nanoc-2.1.6 lib/nanoc/base/proxies/layout_proxy.rb
nanoc-2.2 lib/nanoc/base/proxies/layout_proxy.rb
nanoc-2.2.2 lib/nanoc/base/proxies/layout_proxy.rb
nanoc-2.1 lib/nanoc/base/proxies/layout_proxy.rb
nanoc-2.1.1 lib/nanoc/base/proxies/layout_proxy.rb
nanoc-2.1.2 lib/nanoc/base/proxies/layout_proxy.rb
nanoc-2.1.3 lib/nanoc/base/proxies/layout_proxy.rb
nanoc-2.1.4 lib/nanoc/base/proxies/layout_proxy.rb
nanoc-2.1.5 lib/nanoc/base/proxies/layout_proxy.rb
nanoc-2.2.1 lib/nanoc/base/proxies/layout_proxy.rb