Skip to content

Instantly share code, notes, and snippets.

@elrayle
Created January 20, 2016 17:21
Show Gist options
  • Select an option

  • Save elrayle/949b278782fa2ca25ca5 to your computer and use it in GitHub Desktop.

Select an option

Save elrayle/949b278782fa2ca25ca5 to your computer and use it in GitHub Desktop.
Allocate object from object_profile.
def allocate_object
active_fedora_class.allocate.init_with_json(profile_json) do |allocated_object|
create_key = allocated_object.indexing_service.class.create_time_solr_name
modified_key = allocated_object.indexing_service.class.modified_time_solr_name
allocated_object.resource.set_value(:create_date, DateTime.parse(solr_doc[create_key])) if solr_doc[create_key]
allocated_object.resource.set_value(:modified_date, DateTime.parse(solr_doc[modified_key])) if solr_doc[modified_key]
end
end
@elrayle
Copy link
Copy Markdown
Author

elrayle commented Jan 20, 2016

From active_fedora gem /lib/active_fedora/solr_instance_loader.rb
profile_json = the json from the object_profile field in the solr doc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment