Class: Velocity::Instance::SearchCollection

Inherits:
APIModel
  • Object
show all
Defined in:
lib/acceleration/velocity.rb

Overview

SearchCollection models a Velocity search collection and provides a set of convenience methods for accessing its status, controlling its activity, and even enqueuing documents and URLs.

Defined Under Namespace

Classes: Annotation, CollectionService, Crawler, Indexer, Status

Instance Attribute Summary collapse

Attributes inherited from APIModel

#instance

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from APIModel

#method_missing, #resolve, #respond_to_missing?

Constructor Details

#initialize(collection_name) ⇒ SearchCollection

Create a new SearchCollection wrapper.



659
660
661
# File 'lib/acceleration/velocity.rb', line 659

def initialize(collection_name)
  @name = collection_name
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Velocity::Instance::APIModel

Instance Attribute Details

#nameObject

The name of the collection.



652
653
654
# File 'lib/acceleration/velocity.rb', line 652

def name
  @name
end

Class Method Details

.new_from_xml(args) ⇒ Object

call-seq:

SearchCollection.new_from_xml(:xml => xml, :instance => instance)

Factory method used by Instance#collections



669
670
671
672
673
# File 'lib/acceleration/velocity.rb', line 669

def self.new_from_xml(args)
  sc = SearchCollection.new(args[:xml].attributes['name'].to_s)
  sc.instance = args[:instance]
  sc
end

Instance Method Details

#auto_classify_refresh_tagsObject

Refresh the tags on an auto-classified collection.

Raises:

  • (NotImplementedError)


705
706
707
708
# File 'lib/acceleration/velocity.rb', line 705

def auto_classify_refresh_tags
  # api_method = __method__.dasherize
  raise NotImplementedError
end

#crawlerObject

Get a handle on the crawler service.



678
679
680
# File 'lib/acceleration/velocity.rb', line 678

def crawler
  Crawler.new self
end

#indexerObject

Get a handle on the indexer service.



685
686
687
# File 'lib/acceleration/velocity.rb', line 685

def indexer
  Indexer.new self
end

#prefixObject

The SearchCollection prefix is search-collection.



654
655
656
# File 'lib/acceleration/velocity.rb', line 654

def prefix
  'search-collection'
end

#set_xml(args = {}) ⇒ Object

Set collection XML

This is more appropriate for collections than Repository#update because it correctly separates parts of the collection configuration that must go into the repository from parts that are saved in a status file.



717
718
719
# File 'lib/acceleration/velocity.rb', line 717

def set_xml(args = {})
  instance.call resolve('set-xml'), args.merge(collection: name)
end

#status(_args = {}) ⇒ Object

Retrieve the status of the collection.

Optionally pass :subcollection => ‘live’ or ‘staging’ to choose which subcollection. Default is ‘live’.

Optionally pass :‘stale-ok’ boolean to receive stats that may be behind.



698
699
700
# File 'lib/acceleration/velocity.rb', line 698

def status(_args = {})
  Status.new instance.call resolve('status'), collection: name
end

#xml(args = {}) ⇒ Object

Get collection XML

Pull the collection from the collection service or using a saved copy

Optionally pass :‘stale-ok’ => true or false to indicate if a stale copy is OK. Requesting a fresh copy may extend the request. Default is false.



730
731
732
733
# File 'lib/acceleration/velocity.rb', line 730

def xml(args = {})
  instance.call resolve('xml'),
                { collection: name, :'stale-ok' => false }.merge(args)
end