Sha256: 93c38d86cff71187baf9a8eb5eae43358be7a45026883a602560ca38cf6d596e

Contents?: true

Size: 611 Bytes

Versions: 1

Compression:

Stored size: 611 Bytes

Contents

module Nanoc2

  # Nanoc2::AssetRepProxy is a proxy object for an asset representation
  # (Nanoc2::AssetRep).
  class AssetRepProxy < Proxy

    # Requests the asset representation 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 == :name
        @obj.name
      elsif real_key == :path
        @obj.web_path
      elsif real_key == :asset
        @obj.asset.to_proxy
      else
        super(key)
      end
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nanoc2-2.2.3 lib/nanoc2/base/proxies/asset_rep_proxy.rb