Class: Hyrax::SolrDocumentBehavior::ModelWrapper
- Inherits:
-
Object
- Object
- Hyrax::SolrDocumentBehavior::ModelWrapper
- Defined in:
- app/models/concerns/hyrax/solr_document_behavior.rb
Overview
Note:
access this via #to_model.
Given a model class and an id, provides ActiveModel style model methods.
Instance Method Summary collapse
-
#initialize(model, id) ⇒ ModelWrapper
constructor
private
A new instance of ModelWrapper.
- #model_name ⇒ Object
- #persisted? ⇒ Boolean
- #to_global_id ⇒ Object
- #to_param ⇒ Object
- #to_partial_path ⇒ Object
Constructor Details
#initialize(model, id) ⇒ ModelWrapper
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of ModelWrapper.
52 53 54 55 |
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 52 def initialize(model, id) @model = model @id = id end |
Instance Method Details
#model_name ⇒ Object
71 72 73 |
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 71 def model_name @model.model_name end |
#persisted? ⇒ Boolean
59 60 61 |
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 59 def persisted? true end |
#to_global_id ⇒ Object
89 90 91 |
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 89 def to_global_id URI::GID.build app: GlobalID.app, model_name: model_name.name, model_id: @id end |
#to_param ⇒ Object
65 66 67 |
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 65 def to_param @id end |
#to_partial_path ⇒ Object
Note:
uses the @model’s ‘._to_partial_path` if implemented, otherwise constructs a default
80 81 82 83 84 85 |
# File 'app/models/concerns/hyrax/solr_document_behavior.rb', line 80 def to_partial_path return @model._to_partial_path if @model.respond_to?(:_to_partial_path) "hyrax/#{model_name.collection}/#{model_name.element}" end |