module ActiveFedora::LoadableFromJson

def init_with_json(json)

Parameters:
  • json (String) -- json to be parsed into attributes
def init_with_json(json)
  attrs = JSON.parse(json)
  id = attrs.delete('id')
  @ldp_source = build_ldp_resource(id)
  @association_cache = {}
  datastream_keys = self.class.child_resource_reflections.keys
  datastream_keys.each do |key|
    attached_files[key] = SolrBackedMetadataFile.new
  end
  @resource = SolrBackedResource.new(self.class)
  self.attributes = attrs.slice(*self.class.attribute_names)
  # TODO Should we clear the change tracking, or make this object Read-only?
  run_callbacks :find
  run_callbacks :initialize
  freeze
  self
end