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::ImmutableSortedSetOf, Contracts::PATH_MATCHER

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

Parameters:


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

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


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

def target
  @target
end

Instance Method Details

#content_typeObject


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

def content_type
  mime_type = super
  return mime_type if mime_type

  target_resource.content_type
end

#file_descriptorObject


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

def file_descriptor
  target_resource.file_descriptor
end

#localsObject


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

def locals
  target_resource.locals.deep_merge super
end

#optionsObject


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

def options
  target_resource.options.deep_merge super
end

#pageObject


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

def page
  target_resource.page.deep_merge super
end

#target_resourceObject


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

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


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

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