Module: Hyrax::Ingest::Fetcher
- Defined in:
- lib/hyrax/ingest/fetcher.rb,
lib/hyrax/ingest/fetcher/base.rb,
lib/hyrax/ingest/fetcher/literal.rb,
lib/hyrax/ingest/fetcher/rdf_uri.rb,
lib/hyrax/ingest/fetcher/csv_file.rb,
lib/hyrax/ingest/fetcher/xml_file.rb,
lib/hyrax/ingest/fetcher/date_time.rb,
lib/hyrax/ingest/fetcher/yaml_file.rb,
lib/hyrax/ingest/fetcher/premis_event_type.rb
Defined Under Namespace
Classes: Base, CSVFile, DateTime, Literal, PremisEventType, RdfUri, XMLFile, YAMLFile
Class Method Summary collapse
-
.all_classes ⇒ Object
Set The set of all fetcher classes.
-
.factory(class_name, options = {}) ⇒ Object
An instance of the fetcher class.
-
.find_class_by_name(class_name) ⇒ Class
The appropriate fetcher class.
Class Method Details
.all_classes ⇒ Object
Returns Set The set of all fetcher classes.
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/hyrax/ingest/fetcher.rb', line 15 def all_classes @all_classes ||= Set.new.tap do |all_classes| all_classes << Hyrax::Ingest::Fetcher::XMLFile all_classes << Hyrax::Ingest::Fetcher::YAMLFile all_classes << Hyrax::Ingest::Fetcher::CSVFile all_classes << Hyrax::Ingest::Fetcher::Literal all_classes << Hyrax::Ingest::Fetcher::PremisEventType all_classes << Hyrax::Ingest::Fetcher::RdfUri all_classes << Hyrax::Ingest::Fetcher::DateTime end end |
.factory(class_name, options = {}) ⇒ Object
Returns An instance of the fetcher class.
31 32 33 34 |
# File 'lib/hyrax/ingest/fetcher.rb', line 31 def factory(class_name, ={}) ||= {} find_class_by_name(class_name).new() end |
.find_class_by_name(class_name) ⇒ Class
Returns The appropriate fetcher class.
44 45 46 47 48 49 50 51 |
# File 'lib/hyrax/ingest/fetcher.rb', line 44 def find_class_by_name(class_name) found_classes = all_classes.select do |class_const| (class_const.to_s == class_name) || (class_const.to_s =~ /::#{class_name}/) end raise Hyrax::Ingest::Errors::UnknownFetcherClass.new(class_name, all_classes) if found_classes.count == 0 raise Hyrax::Ingest::Errors::AmbiguousFetcherClass.new(class_name, found_classes) if found_classes.count > 1 found_classes.first end |