Class: CurationConcerns::PresenterFactory
- Inherits:
-
Object
- Object
- CurationConcerns::PresenterFactory
- Defined in:
- app/presenters/curation_concerns/presenter_factory.rb
Instance Attribute Summary collapse
-
#args ⇒ Object
readonly
Returns the value of attribute args.
-
#ids ⇒ Object
readonly
Returns the value of attribute ids.
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
Class Method Summary collapse
-
.build_presenters(ids, klass, *args) ⇒ Array
Presenters for the documents in order of the ids.
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(ids, klass, *args) ⇒ PresenterFactory
constructor
A new instance of PresenterFactory.
Constructor Details
#initialize(ids, klass, *args) ⇒ PresenterFactory
Returns a new instance of PresenterFactory.
15 16 17 18 19 |
# File 'app/presenters/curation_concerns/presenter_factory.rb', line 15 def initialize(ids, klass, *args) @ids = ids @klass = klass @args = args end |
Instance Attribute Details
#args ⇒ Object (readonly)
Returns the value of attribute args.
13 14 15 |
# File 'app/presenters/curation_concerns/presenter_factory.rb', line 13 def args @args end |
#ids ⇒ Object (readonly)
Returns the value of attribute ids.
13 14 15 |
# File 'app/presenters/curation_concerns/presenter_factory.rb', line 13 def ids @ids end |
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
13 14 15 |
# File 'app/presenters/curation_concerns/presenter_factory.rb', line 13 def klass @klass end |
Class Method Details
.build_presenters(ids, klass, *args) ⇒ Array
Returns presenters for the documents in order of the ids.
8 9 10 |
# File 'app/presenters/curation_concerns/presenter_factory.rb', line 8 def build_presenters(ids, klass, *args) new(ids, klass, *args).build end |
Instance Method Details
#build ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'app/presenters/curation_concerns/presenter_factory.rb', line 21 def build return [] if ids.blank? docs = load_docs ids.map do |id| solr_doc = docs.find { |doc| doc.id == id } klass.new(solr_doc, *args) if solr_doc end.compact end |