Module: Hyrax::Ingest::Transformer
- Defined in:
- lib/hyrax/ingest/transformer.rb,
lib/hyrax/ingest/transformer/base.rb,
lib/hyrax/ingest/transformer/to_date.rb
Defined Under Namespace
Class Method Summary collapse
-
.all_classes ⇒ Object
Set The set of all transformer classes.
-
.factory(class_name, options = {}) ⇒ Object
An instance of the transformer class.
-
.find_class_by_name(class_name) ⇒ Class
The appropriate transformer class.
Class Method Details
.all_classes ⇒ Object
Returns Set The set of all transformer classes.
9 10 11 12 13 |
# File 'lib/hyrax/ingest/transformer.rb', line 9 def all_classes @all_classes ||= Set.new.tap do |all_classes| all_classes << Hyrax::Ingest::Transformer::ToDate end end |
.factory(class_name, options = {}) ⇒ Object
Returns An instance of the transformer class.
19 20 21 |
# File 'lib/hyrax/ingest/transformer.rb', line 19 def factory(class_name, ={}) find_class_by_name(class_name).new() end |
.find_class_by_name(class_name) ⇒ Class
Returns The appropriate transformer class.
31 32 33 34 35 36 37 38 |
# File 'lib/hyrax/ingest/transformer.rb', line 31 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::UnknownTransformerClass.new(class_name, all_classes) if found_classes.count == 0 raise Hyrax::Ingest::Errors::AmbiguousTransformerClass.new(class_name, found_classes) if found_classes.count > 1 found_classes.first end |