Class: SiteMaps::Adapters::Adapter
- Inherits:
-
Object
- Object
- SiteMaps::Adapters::Adapter
- Extended by:
- Forwardable
- Defined in:
- lib/site_maps/adapters/adapter.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#processes ⇒ Object
readonly
Returns the value of attribute processes.
-
#sitemap_index ⇒ Object
readonly
Returns the value of attribute sitemap_index.
Class Method Summary collapse
Instance Method Summary collapse
- #config {|@config| ... } ⇒ Object (also: #configure)
- #delete(_url) ⇒ void abstract
- #include_module(mod) ⇒ Object
-
#initialize(**options, &block) ⇒ Adapter
constructor
A new instance of Adapter.
- #maybe_inline_urlset? ⇒ Boolean
- #process(name = :default, location = nil, **kwargs, &block) ⇒ Object
-
#read(_url) ⇒ Array<String, Hash>
abstract
The raw data and metadata.
- #repo ⇒ Object
- #reset! ⇒ Object
- #write(_url, _raw_data, **_kwargs) ⇒ void abstract
Constructor Details
#initialize(**options, &block) ⇒ Adapter
Returns a new instance of Adapter.
18 19 20 21 22 23 |
# File 'lib/site_maps/adapters/adapter.rb', line 18 def initialize(**, &block) @config = SiteMaps.config.becomes(self.class.config_class, **) @processes = Concurrent::Hash.new reset! instance_exec(&block) if block end |
Instance Attribute Details
#processes ⇒ Object (readonly)
Returns the value of attribute processes.
16 17 18 |
# File 'lib/site_maps/adapters/adapter.rb', line 16 def processes @processes end |
#sitemap_index ⇒ Object (readonly)
Returns the value of attribute sitemap_index.
16 17 18 |
# File 'lib/site_maps/adapters/adapter.rb', line 16 def sitemap_index @sitemap_index end |
Class Method Details
.config_class ⇒ Object
8 9 10 11 12 |
# File 'lib/site_maps/adapters/adapter.rb', line 8 def config_class return SiteMaps::Configuration unless defined?(self::Config) self::Config end |
Instance Method Details
#config {|@config| ... } ⇒ Object Also known as: configure
50 51 52 53 |
# File 'lib/site_maps/adapters/adapter.rb', line 50 def config yield(@config) if block_given? @config end |
#delete(_url) ⇒ void
This method is abstract.
This method returns an undefined value.
46 47 48 |
# File 'lib/site_maps/adapters/adapter.rb', line 46 def delete(_url) raise NotImplementedError end |
#include_module(mod) ⇒ Object
71 72 73 |
# File 'lib/site_maps/adapters/adapter.rb', line 71 def include_module(mod) extend(mod) end |
#maybe_inline_urlset? ⇒ Boolean
63 64 65 |
# File 'lib/site_maps/adapters/adapter.rb', line 63 def maybe_inline_urlset? @processes.size == 1 && @processes.first.last.static? end |
#process(name = :default, location = nil, **kwargs, &block) ⇒ Object
56 57 58 59 60 61 |
# File 'lib/site_maps/adapters/adapter.rb', line 56 def process(name = :default, location = nil, **kwargs, &block) name = name.to_sym raise ArgumentError, "Process #{name} already defined" if @processes.key?(name) @processes[name] = SiteMaps::Process.new(name, location, kwargs, block) end |
#read(_url) ⇒ Array<String, Hash>
This method is abstract.
Returns The raw data and metadata.
38 39 40 |
# File 'lib/site_maps/adapters/adapter.rb', line 38 def read(_url) raise NotImplementedError end |
#repo ⇒ Object
67 68 69 |
# File 'lib/site_maps/adapters/adapter.rb', line 67 def repo @repo ||= SiteMaps::AtomicRepository.new(config.url) end |
#reset! ⇒ Object
75 76 77 78 |
# File 'lib/site_maps/adapters/adapter.rb', line 75 def reset! @sitemap_index = SiteMaps::Builder::SitemapIndex.new @repo = nil end |
#write(_url, _raw_data, **_kwargs) ⇒ void
This method is abstract.
This method returns an undefined value.
30 31 32 |
# File 'lib/site_maps/adapters/adapter.rb', line 30 def write(_url, _raw_data, **_kwargs) raise NotImplementedError end |