Class: Middleman::Sitemap::ProxyResource

Inherits:
Resource
  • Object
show all
Defined in:
middleman-core/lib/middleman-core/sitemap/extensions/proxies.rb

Constant Summary

Constants inherited from Resource

Resource::FILTER, Resource::MAYBE_METADATA_CONTRACT, Resource::METADATA_CONTRACT

Constants included from Contracts

Contracts::ImmutableSetOf, Contracts::ImmutableSortedSetOf, Contracts::OldResourceList, Contracts::PATH_MATCHER, Contracts::ResourceList, Contracts::VectorOf

Instance Attribute Summary collapse

Attributes inherited from Resource

#app, #destination_path, #path, #priority, #vertices

Instance Method Summary collapse

Methods inherited from Resource

#<=>, #Any, #Bool, #Hash, #String, #add_filter, #add_metadata, #add_metadata_locals, #add_metadata_options, #add_metadata_page, #binary?, #data, #ext, #ignore!, #ignored?, #metadata, #normalized_path, #page_id, #proxy_to, #render, #render_without_filters, #source_file, #static_file?, #template?, #url

Methods included from Extensions::Traversal

#children, #directory_index?, #eponymous_directory?, #eponymous_directory_path, #parent, #parent_helper, #siblings, #traversal_root

Methods included from Contracts

#Contract

Constructor Details

#initialize(store, path, target) ⇒ ProxyResource

Initialize resource with parent store and URL


75
76
77
78
79
80
81
82
# File 'middleman-core/lib/middleman-core/sitemap/extensions/proxies.rb', line 75

def initialize(store, path, target)
  super(store, path, nil, 2)

  target = ::Middleman::Util.normalize_path(target)
  raise "You can't proxy #{path} to itself!" if target == path

  @target = target
end

Instance Attribute Details

#targetObject (readonly)

Returns the value of attribute target


69
70
71
# File 'middleman-core/lib/middleman-core/sitemap/extensions/proxies.rb', line 69

def target
  @target
end

Instance Method Details

#content_typeObject


116
117
118
119
120
121
# File 'middleman-core/lib/middleman-core/sitemap/extensions/proxies.rb', line 116

def content_type
  mime_type = super
  return mime_type if mime_type

  target_resource.content_type
end

#file_descriptorObject


99
100
101
# File 'middleman-core/lib/middleman-core/sitemap/extensions/proxies.rb', line 99

def file_descriptor
  target_resource.file_descriptor
end

#localsObject


111
112
113
# File 'middleman-core/lib/middleman-core/sitemap/extensions/proxies.rb', line 111

def locals
  target_resource.locals.deep_merge super
end

#optionsObject


107
108
109
# File 'middleman-core/lib/middleman-core/sitemap/extensions/proxies.rb', line 107

def options
  target_resource.options.deep_merge super
end

#pageObject


103
104
105
# File 'middleman-core/lib/middleman-core/sitemap/extensions/proxies.rb', line 103

def page
  target_resource.page.deep_merge super
end

#target_resourceObject


88
89
90
91
92
93
94
95
96
# File 'middleman-core/lib/middleman-core/sitemap/extensions/proxies.rb', line 88

def target_resource
  resource = @store.by_path(@target)

  raise "Path #{path} proxies to unknown file #{@target}" unless resource

  raise "You can't proxy #{path} to #{@target} which is itself a proxy." if resource.is_a? ProxyResource

  resource
end

#to_sObject Also known as: inspect


123
124
125
# File 'middleman-core/lib/middleman-core/sitemap/extensions/proxies.rb', line 123

def to_s
  "#<#{self.class} path=#{@path} target=#{@target}>"
end