Module: ActiveFedora

Extended by:
ActiveSupport::Autoload
Defined in:
lib/active_fedora.rb,
lib/active_fedora/rdf.rb,
lib/active_fedora/base.rb,
lib/active_fedora/core.rb,
lib/active_fedora/file.rb,
lib/active_fedora/type.rb,
lib/active_fedora/common.rb,
lib/active_fedora/config.rb,
lib/active_fedora/errors.rb,
lib/active_fedora/fedora.rb,
lib/active_fedora/orders.rb,
lib/active_fedora/schema.rb,
lib/active_fedora/cleaner.rb,
lib/active_fedora/file_io.rb,
lib/active_fedora/pathing.rb,
lib/active_fedora/railtie.rb,
lib/active_fedora/scoping.rb,
lib/active_fedora/version.rb,
lib/active_fedora/checksum.rb,
lib/active_fedora/indexers.rb,
lib/active_fedora/indexing.rb,
lib/active_fedora/property.rb,
lib/active_fedora/querying.rb,
lib/active_fedora/relation.rb,
lib/active_fedora/solr_hit.rb,
lib/active_fedora/callbacks.rb,
lib/active_fedora/ldp_cache.rb,
lib/active_fedora/attributes.rb,
lib/active_fedora/change_set.rb,
lib/active_fedora/files_hash.rb,
lib/active_fedora/reflection.rb,
lib/active_fedora/type/value.rb,
lib/active_fedora/aggregation.rb,
lib/active_fedora/inheritance.rb,
lib/active_fedora/null_logger.rb,
lib/active_fedora/persistence.rb,
lib/active_fedora/validations.rb,
lib/active_fedora/versionable.rb,
lib/active_fedora/associations.rb,
lib/active_fedora/identifiable.rb,
lib/active_fedora/ldp_resource.rb,
lib/active_fedora/solr_service.rb,
lib/active_fedora/test_support.rb,
lib/active_fedora/type/boolean.rb,
lib/active_fedora/file_relation.rb,
lib/active_fedora/null_relation.rb,
lib/active_fedora/scoping/named.rb,
lib/active_fedora/serialization.rb,
lib/active_fedora/sparql_insert.rb,
lib/active_fedora/with_metadata.rb,
lib/active_fedora/attached_files.rb,
lib/active_fedora/fixity_service.rb,
lib/active_fedora/log_subscriber.rb,
lib/active_fedora/rspec_matchers.rb,
lib/active_fedora/versions_graph.rb,
lib/active_fedora/indexing/suffix.rb,
lib/active_fedora/rdf/persistence.rb,
lib/active_fedora/relation/merger.rb,
lib/active_fedora/scoping/default.rb,
lib/active_fedora/association_hash.rb,
lib/active_fedora/associations/rdf.rb,
lib/active_fedora/clean_connection.rb,
lib/active_fedora/file_persistence.rb,
lib/active_fedora/indexing_service.rb,
lib/active_fedora/model_classifier.rb,
lib/active_fedora/runtime_registry.rb,
lib/active_fedora/attribute_methods.rb,
lib/active_fedora/fedora_attributes.rb,
lib/active_fedora/file_configurator.rb,
lib/active_fedora/file_path_builder.rb,
lib/active_fedora/indexing/inserter.rb,
lib/active_fedora/nested_attributes.rb,
lib/active_fedora/caching_connection.rb,
lib/active_fedora/loadable_from_json.rb,
lib/active_fedora/solr_query_builder.rb,
lib/active_fedora/delegated_attribute.rb,
lib/active_fedora/indexing/descriptor.rb,
lib/active_fedora/orders/ordered_list.rb,
lib/active_fedora/orders/target_proxy.rb,
lib/active_fedora/relation/delegation.rb,
lib/active_fedora/association_relation.rb,
lib/active_fedora/attribute_assignment.rb,
lib/active_fedora/autosave_association.rb,
lib/active_fedora/containers/container.rb,
lib/active_fedora/default_model_mapper.rb,
lib/active_fedora/ldp_resource_service.rb,
lib/active_fedora/query_result_builder.rb,
lib/active_fedora/indexing/field_mapper.rb,
lib/active_fedora/inheritable_accessors.rb,
lib/active_fedora/relation/calculations.rb,
lib/active_fedora/attribute_methods/read.rb,
lib/active_fedora/attributes/primary_key.rb,
lib/active_fedora/attributes/serializers.rb,
lib/active_fedora/relation/query_methods.rb,
lib/active_fedora/relation/spawn_methods.rb,
lib/active_fedora/aggregation/list_source.rb,
lib/active_fedora/attribute_methods/dirty.rb,
lib/active_fedora/attribute_methods/write.rb,
lib/active_fedora/initializing_connection.rb,
lib/active_fedora/orders/collection_proxy.rb,
lib/active_fedora/relation/finder_methods.rb,
lib/active_fedora/associations/association.rb,
lib/active_fedora/schema_indexing_strategy.rb,
lib/active_fedora/associations/singular_rdf.rb,
lib/active_fedora/containers/direct_container.rb,
lib/active_fedora/inbound_relation_connection.rb,
lib/active_fedora/indexing/descendant_fetcher.rb,
lib/active_fedora/with_metadata/metadata_node.rb,
lib/active_fedora/associations/container_proxy.rb,
lib/active_fedora/indexing/default_descriptors.rb,
lib/active_fedora/associations/collection_proxy.rb,
lib/active_fedora/containers/indirect_container.rb,
lib/active_fedora/associations/association_scope.rb,
lib/generators/active_fedora/model/model_generator.rb,
lib/active_fedora/associations/contains_association.rb,
lib/active_fedora/associations/has_many_association.rb,
lib/active_fedora/associations/singular_association.rb,
lib/active_fedora/attributes/active_triple_attribute.rb,
lib/generators/active_fedora/config/config_generator.rb,
lib/active_fedora/associations/belongs_to_association.rb,
lib/active_fedora/associations/collection_association.rb,
lib/active_fedora/persistence/null_identifier_service.rb,
lib/generators/active_fedora/config/solr/solr_generator.rb,
lib/active_fedora/associations/basic_contains_association.rb,
lib/active_fedora/associations/has_subresource_association.rb,
lib/generators/active_fedora/config/fedora/fedora_generator.rb,
lib/active_fedora/associations/directly_contains_association.rb,
lib/active_fedora/associations/indirectly_contains_association.rb,
lib/active_fedora/associations/directly_contains_one_association.rb,
lib/active_fedora/associations/has_and_belongs_to_many_association.rb

Overview

This is the parent class of BasicContainsAssociation, DirectlyContainsAssociation and IndirectlyContainsAssociation

Defined Under Namespace

Modules: Aggregation, Associations, AttachedFiles, AttributeAssignment, AttributeMethods, Attributes, AutosaveAssociation, Calculations, Callbacks, Cleaner, Common, Core, Delegation, FedoraAttributes, FilePersistence, FinderMethods, Identifiable, Indexers, Indexing, InheritableAccessors, Inheritance, LoadableFromJson, NestedAttributes, NullRelation, Orders, Pathing, Persistence, QueryMethods, QueryResultBuilder, Querying, RDF, Reflection, RspecMatchers, Schema, Scoping, Serialization, SolrQueryBuilder, SpawnMethods, TestSupport, Type, Validations, Versionable, WithMetadata Classes: ActiveFedoraError, ActiveTripleAttribute, AlreadyPersistedError, AssociationHash, AssociationNotFoundError, AssociationRelation, AssociationTypeMismatch, Base, CachingConnection, ChangeSet, Checksum, CleanConnection, Config, ConfigGenerator, ConfigurationError, ConstraintError, Container, DangerousAttributeError, DefaultModelMapper, DelegatedAttribute, DeleteRestrictionError, DirectContainer, Fedora, FedoraStatement, File, FileConfigurator, FileIO, FilePathBuilder, FileRelation, FilesHash, FixityService, IllegalOperation, InboundRelationConnection, IndexingService, IndirectContainer, InitializingConnection, InverseOfAssociationNotFoundError, LdpCache, LdpResource, LdpResourceService, LogSubscriber, MaybeHashUri, Merged, ModelClassifier, ModelGenerator, ModelMismatch, NullLogger, ObjectNotFoundError, Property, Railtie, ReadOnlyRecord, RecordInvalid, RecordNotDestroyed, RecordNotSaved, Relation, Rollback, RuntimeRegistry, SchemaIndexingStrategy, SolrHit, SolrService, SparqlInsert, UnknownAttributeError, VersionLacksCreateDate, VersionsGraph

Constant Summary collapse

VERSION =
'13.2.0'.freeze

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.config_optionsObject (readonly)

Returns the value of attribute config_options.



157
158
159
# File 'lib/active_fedora.rb', line 157

def config_options
  @config_options
end

.configuratorObject

Returns the value of attribute configurator.



158
159
160
# File 'lib/active_fedora.rb', line 158

def configurator
  @configurator
end

.fedora_configObject (readonly)

Returns the value of attribute fedora_config.



157
158
159
# File 'lib/active_fedora.rb', line 157

def fedora_config
  @fedora_config
end

.solr_configObject (readonly)

Returns the value of attribute solr_config.



157
158
159
# File 'lib/active_fedora.rb', line 157

def solr_config
  @solr_config
end

Class Method Details

.class_from_string(*args) ⇒ Object

Convenience method for getting class constant based on a string

Examples:

ActiveFedora.class_from_string("Om")
=> Om
ActiveFedora.class_from_string("ActiveFedora::RdfNode::TermProxy")
=> ActiveFedora::RdfNode::TermProxy

Search within ActiveFedora::RdfNode for a class called “TermProxy”

ActiveFedora.class_from_string("TermProxy", ActiveFedora::RdfNode)
=> ActiveFedora::RdfNode::TermProxy


236
237
238
# File 'lib/active_fedora.rb', line 236

def class_from_string(*args)
  ActiveFedora::ModelClassifier.class_from_string(*args)
end

.configObject



183
184
185
# File 'lib/active_fedora.rb', line 183

def config
  fedora_config
end

.eager_load!Object

ActiveSupport::Autoload automatically defines an eager_load! method. In this case, we are extending the method to also eager load the components inside ActiveFedora.



268
269
270
271
272
273
274
275
276
277
278
# File 'lib/active_fedora.rb', line 268

def eager_load!
  super
  ActiveFedora::Scoping.eager_load!
  ActiveFedora::Aggregation.eager_load!
  ActiveFedora::Associations.eager_load!
  ActiveFedora::Attributes.eager_load!
  ActiveFedora::AttributeMethods.eager_load!
  ActiveFedora::Indexers.eager_load!
  ActiveFedora::Indexing.eager_load!
  ActiveFedora::Orders.eager_load!
end

.enable_solr_updates?Boolean

Returns:

  • (Boolean)


256
257
258
259
260
261
262
# File 'lib/active_fedora.rb', line 256

def enable_solr_updates?
  if defined?(ENABLE_SOLR_UPDATES)
    ENABLE_SOLR_UPDATES
  else
    true
  end
end

.environmentString

Determine what environment we’re running in. Order of preference is:

  1. config_options

  2. Rails.env

  3. ENV

  4. ENV

  5. development

Examples:

ActiveFedora.init(:environment=>"test")
ActiveFedora.environment => "test"

Returns:

  • (String)


197
198
199
200
201
202
203
204
205
206
207
208
209
# File 'lib/active_fedora.rb', line 197

def environment
  if config_options.fetch(:environment, nil)
    config_options[:environment]
  elsif defined?(Rails.env) && !Rails.env.nil?
    Rails.env.to_s
  elsif defined?(ENV['environment']) && !ENV['environment'].nil?
    ENV['environment']
  elsif defined?(ENV['RAILS_ENV']) && !ENV['RAILS_ENV'].nil?
    raise "You're depending on RAILS_ENV for setting your environment. Please use ENV['environment'] for non-rails environment setting: 'rake foo:bar environment=test'"
  else
    ENV['environment'] = 'development'
  end
end

.fedoraObject



215
216
217
# File 'lib/active_fedora.rb', line 215

def fedora
  ActiveFedora::Fedora.instance
end

.id_fieldObject



248
249
250
251
252
253
254
# File 'lib/active_fedora.rb', line 248

def id_field
  if defined?(SOLR_DOCUMENT_ID) && !SOLR_DOCUMENT_ID.nil?
    SOLR_DOCUMENT_ID
  else
    ActiveFedora.index_field_mapper.id_field
  end
end

.index_field_mapperObject



244
245
246
# File 'lib/active_fedora.rb', line 244

def index_field_mapper
  @index_field_mapper ||= Indexing::FieldMapper.new
end

.init(options = {}) ⇒ Object



170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/active_fedora.rb', line 170

def init(options = {})
  # Make config_options into a Hash if nil is passed in as the value
  options = {} if options.nil?
  # For backwards compatibility, handle cases where config_path (a String) is passed in as the argument rather than a config_options hash
  # In all other cases, set config_path to config_options[:config_path], which is ok if it's nil
  if options.is_a? String
    raise ArgumentError, "Calling ActiveFedora.init with a path as an argument has been removed.  Use ActiveFedora.init(:fedora_config_path=>#{options})"
  end
  @fedora_config = nil
  SolrService.reset!
  configurator.init(options)
end

.model_mapperObject



240
241
242
# File 'lib/active_fedora.rb', line 240

def model_mapper
  ActiveFedora::DefaultModelMapper.new
end

.rootObject



219
220
221
# File 'lib/active_fedora.rb', line 219

def root
  ::File.expand_path('../..', __FILE__)
end

.solrObject



211
212
213
# File 'lib/active_fedora.rb', line 211

def solr
  ActiveFedora::SolrService.instance
end

.versionObject



223
224
225
# File 'lib/active_fedora.rb', line 223

def version
  ActiveFedora::VERSION
end