Sha256: 43eb43b8e0599103c5c4272412a2175199f4b2195380a6cce256206b39a53c57

Contents?: true

Size: 583 Bytes

Versions: 1

Compression:

Stored size: 583 Bytes

Contents

module Nanoc
  class PageProxy

    def initialize(page, params={})
      @page       = page
      @do_filter  = (params[:filter] != false)
    end

    def [](key)
      if key.to_sym == :content and @do_filter
        @page.content
      elsif key.to_sym == :file
        @page.file
      elsif key.to_s.ends_with?('?')
        @page.attributes[key.to_s[0..-2].to_sym]
      else
        @page.attributes[key]
      end
    end

    def []=(key, value)
      @page.attributes[key.to_sym] = value
    end

    def method_missing(method, *args)
      self[method]
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nanoc-1.6.2 lib/nanoc/page_proxy.rb