Class: Middleman::Sitemap::ProxyResource
- Defined in:
- lib/middleman-core/sitemap/extensions/proxies.rb
Constant Summary
Constants inherited from Resource
Constants included from Contracts
Instance Attribute Summary collapse
-
#target ⇒ Object
readonly
Returns the value of attribute target.
Attributes inherited from Resource
#destination_path, #ignored, #path
Instance Method Summary collapse
- #content_type ⇒ Object
- #file_descriptor ⇒ Object
-
#initialize(store, path, target) ⇒ ProxyResource
constructor
Initialize resource with parent store and URL.
- #metadata ⇒ Object
- #target_resource ⇒ Object
- #to_s ⇒ Object (also: #inspect)
Methods inherited from Resource
#Any, #Bool, #Hash, #METADATA_HASH, #String, #add_metadata, #binary?, #data, #ext, #ignore!, #ignored?, #indifferent_access?, #locals, #options, #proxy_to, #render, #source_file, #template?, #url
Methods included from Extensions::Traversal
#children, #directory_index?, #eponymous_directory?, #eponymous_directory_path, #parent, #siblings, #traversal_root
Methods included from Contracts
Constructor Details
#initialize(store, path, target) ⇒ ProxyResource
Initialize resource with parent store and URL
70 71 72 73 74 75 76 |
# File 'lib/middleman-core/sitemap/extensions/proxies.rb', line 70 def initialize(store, path, target) super(store, path) target = ::Middleman::Util.normalize_path(target) raise "You can't proxy #{path} to itself!" if target == path @target = target end |
Instance Attribute Details
#target ⇒ Object (readonly)
Returns the value of attribute target.
64 65 66 |
# File 'lib/middleman-core/sitemap/extensions/proxies.rb', line 64 def target @target end |
Instance Method Details
#content_type ⇒ Object
106 107 108 109 110 111 |
# File 'lib/middleman-core/sitemap/extensions/proxies.rb', line 106 def content_type mime_type = super return mime_type if mime_type target_resource.content_type end |
#file_descriptor ⇒ Object
97 98 99 |
# File 'lib/middleman-core/sitemap/extensions/proxies.rb', line 97 def file_descriptor target_resource.file_descriptor end |
#metadata ⇒ Object
101 102 103 |
# File 'lib/middleman-core/sitemap/extensions/proxies.rb', line 101 def target_resource..deep_merge super end |
#target_resource ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/middleman-core/sitemap/extensions/proxies.rb', line 82 def target_resource resource = @store.find_resource_by_path(@target) unless resource raise "Path #{path} proxies to unknown file #{@target}:#{@store.resources.map(&:path)}" end if resource.is_a? ProxyResource raise "You can't proxy #{path} to #{@target} which is itself a proxy." end resource end |
#to_s ⇒ Object Also known as: inspect
113 114 115 |
# File 'lib/middleman-core/sitemap/extensions/proxies.rb', line 113 def to_s "#<#{self.class} path=#{@path} target=#{@target}>" end |