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, #page_id, #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
73 74 75 76 77 78 79 |
# File 'lib/middleman-core/sitemap/extensions/proxies.rb', line 73 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.
67 68 69 |
# File 'lib/middleman-core/sitemap/extensions/proxies.rb', line 67 def target @target end |
Instance Method Details
#content_type ⇒ Object
109 110 111 112 113 114 |
# File 'lib/middleman-core/sitemap/extensions/proxies.rb', line 109 def content_type mime_type = super return mime_type if mime_type target_resource.content_type end |
#file_descriptor ⇒ Object
100 101 102 |
# File 'lib/middleman-core/sitemap/extensions/proxies.rb', line 100 def file_descriptor target_resource.file_descriptor end |
#metadata ⇒ Object
104 105 106 |
# File 'lib/middleman-core/sitemap/extensions/proxies.rb', line 104 def target_resource..deep_merge super end |
#target_resource ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/middleman-core/sitemap/extensions/proxies.rb', line 85 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
116 117 118 |
# File 'lib/middleman-core/sitemap/extensions/proxies.rb', line 116 def to_s "#<#{self.class} path=#{@path} target=#{@target}>" end |