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/model.rb,
lib/active_fedora/fedora.rb,
lib/active_fedora/config.rb,
lib/active_fedora/errors.rb,
lib/active_fedora/scoping.rb,
lib/active_fedora/railtie.rb,
lib/active_fedora/cleaner.rb,
lib/active_fedora/version.rb,
lib/active_fedora/relation.rb,
lib/active_fedora/indexing.rb,
lib/active_fedora/querying.rb,
lib/active_fedora/property.rb,
lib/active_fedora/ldp_cache.rb,
lib/active_fedora/callbacks.rb,
lib/active_fedora/change_set.rb,
lib/active_fedora/datastream.rb,
lib/active_fedora/predicates.rb,
lib/active_fedora/attributes.rb,
lib/active_fedora/files_hash.rb,
lib/active_fedora/reflection.rb,
lib/active_fedora/datastreams.rb,
lib/active_fedora/validations.rb,
lib/active_fedora/persistence.rb,
lib/active_fedora/versionable.rb,
lib/active_fedora/test_support.rb,
lib/active_fedora/ldp_resource.rb,
lib/active_fedora/solr_service.rb,
lib/active_fedora/associations.rb,
lib/active_fedora/om_datastream.rb,
lib/active_fedora/scoping/named.rb,
lib/active_fedora/sparql_insert.rb,
lib/active_fedora/serialization.rb,
lib/active_fedora/with_metadata.rb,
lib/active_fedora/null_relation.rb,
lib/active_fedora/log_subscriber.rb,
lib/active_fedora/fixity_service.rb,
lib/active_fedora/nom_datastream.rb,
lib/active_fedora/rspec_matchers.rb,
lib/active_fedora/attached_files.rb,
lib/active_fedora/versions_graph.rb,
lib/active_fedora/scoping/default.rb,
lib/active_fedora/rdf/persistence.rb,
lib/active_fedora/relation/merger.rb,
lib/active_fedora/associations/rdf.rb,
lib/active_fedora/indexing_service.rb,
lib/active_fedora/file_path_builder.rb,
lib/active_fedora/fedora_attributes.rb,
lib/active_fedora/simple_datastream.rb,
lib/active_fedora/file_configurator.rb,
lib/active_fedora/nested_attributes.rb,
lib/active_fedora/attribute_methods.rb,
lib/active_fedora/solr_query_builder.rb,
lib/active_fedora/rdf/rdf_datastream.rb,
lib/active_fedora/caching_connection.rb,
lib/active_fedora/loadable_from_json.rb,
lib/active_fedora/delegated_attribute.rb,
lib/active_fedora/relation/delegation.rb,
lib/active_fedora/query_result_builder.rb,
lib/active_fedora/autosave_association.rb,
lib/active_fedora/association_relation.rb,
lib/active_fedora/ldp_resource_service.rb,
lib/active_fedora/solr_instance_loader.rb,
lib/active_fedora/relation/calculations.rb,
lib/active_fedora/rdf/rdfxml_datastream.rb,
lib/active_fedora/relation/query_methods.rb,
lib/active_fedora/attribute_methods/read.rb,
lib/active_fedora/relation/spawn_methods.rb,
lib/active_fedora/attributes/primary_key.rb,
lib/active_fedora/attributes/serializers.rb,
lib/active_fedora/attribute_methods/dirty.rb,
lib/active_fedora/attribute_methods/write.rb,
lib/active_fedora/relation/finder_methods.rb,
lib/active_fedora/associations/association.rb,
lib/active_fedora/profile_indexing_service.rb,
lib/active_fedora/associations/singular_rdf.rb,
lib/active_fedora/with_metadata/metadata_node.rb,
lib/active_fedora/rdf/ntriples_rdf_datastream.rb,
lib/active_fedora/associations/collection_proxy.rb,
lib/active_fedora/associations/association_scope.rb,
lib/generators/active_fedora/model/model_generator.rb,
lib/active_fedora/qualified_dublin_core_datastream.rb,
lib/active_fedora/datastreams/nokogiri_datastreams.rb,
lib/active_fedora/associations/has_many_association.rb,
lib/active_fedora/associations/singular_association.rb,
lib/active_fedora/associations/contains_association.rb,
lib/generators/active_fedora/config/config_generator.rb,
lib/active_fedora/associations/collection_association.rb,
lib/active_fedora/associations/belongs_to_association.rb,
lib/generators/active_fedora/config/solr/solr_generator.rb,
lib/generators/active_fedora/config/fedora/fedora_generator.rb,
lib/active_fedora/associations/has_and_belongs_to_many_association.rb

Overview

:nodoc:

Defined Under Namespace

Modules: Associations, AttachedFiles, AttributeMethods, Attributes, AutosaveAssociation, Calculations, Callbacks, Cleaner, Core, Datastreams, Delegation, FedoraAttributes, FinderMethods, Indexing, LoadableFromJson, Model, NestedAttributes, NullRelation, Persistence, Predicates, QueryMethods, QueryResultBuilder, Querying, RDF, Reflection, RspecMatchers, Scoping, Serialization, SolrQueryBuilder, SpawnMethods, TestSupport, Validations, Versionable, WithMetadata Classes: ActiveFedoraError, AssociationRelation, AssociationTypeMismatch, Base, CachingConnection, ChangeSet, Config, ConfigGenerator, ConfigurationError, ConstraintError, Datastream, DelegatedAttribute, Fedora, FedoraSolrMismatchError, File, FileConfigurator, FilePathBuilder, FilesHash, FixityService, IllegalOperation, IndexingService, InverseOfAssociationNotFoundError, LdpCache, LdpResource, LdpResourceService, LogSubscriber, ModelGenerator, NomDatastream, NtriplesRDFDatastream, ObjectNotFoundError, OmDatastream, PredicateMappingsNotFoundError, ProfileIndexingService, Property, QualifiedDublinCoreDatastream, RDFDatastream, RDFXMLDatastream, Railtie, ReadOnlyRecord, RecordInvalid, RecordNotSaved, Relation, Rollback, SimpleDatastream, SolrInstanceLoader, SolrNotInitialized, SolrService, SparqlInsert, UnknownAttributeError, UnregisteredPredicateError, VersionsGraph

Constant Summary

VERSION =
"9.0.4"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.config_optionsObject (readonly)

Returns the value of attribute config_options



145
146
147
# File 'lib/active_fedora.rb', line 145

def config_options
  @config_options
end

.configuratorObject

Returns the value of attribute configurator



146
147
148
# File 'lib/active_fedora.rb', line 146

def configurator
  @configurator
end

.fedora_configObject (readonly)

Returns the value of attribute fedora_config



145
146
147
# File 'lib/active_fedora.rb', line 145

def fedora_config
  @fedora_config
end

.solr_configObject (readonly)

Returns the value of attribute solr_config



145
146
147
# File 'lib/active_fedora.rb', line 145

def solr_config
  @solr_config
end

Class Method Details

.class_from_string(class_name, container_class = Kernel) ⇒ 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


226
227
228
229
230
231
232
233
234
235
236
237
238
239
# File 'lib/active_fedora.rb', line 226

def class_from_string(class_name, container_class=Kernel)
  container_class = container_class.name if container_class.is_a? Module
  container_parts = container_class.split('::')
  (container_parts + class_name.split('::')).flatten.inject(Kernel) do |mod, class_name|
    if mod == Kernel
      Object.const_get(class_name)
    elsif mod.const_defined? class_name.to_sym
      mod.const_get(class_name)
    else
      container_parts.pop
      class_from_string(class_name, container_parts.join('::'))
    end
  end
end

.configObject



169
170
171
# File 'lib/active_fedora.rb', line 169

def config
  fedora_config
end

.config_loaded?Boolean



153
# File 'lib/active_fedora.rb', line 153

def config_loaded?; configurator.config_loaded?; 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"


183
184
185
186
187
188
189
190
191
192
193
194
195
# File 'lib/active_fedora.rb', line 183

def environment
  if config_options.fetch(:environment,nil)
    return config_options[:environment]
  elsif defined?(Rails.env) and !Rails.env.nil?
    return Rails.env.to_s
  elsif defined?(ENV['environment']) and !(ENV['environment'].nil?)
    return ENV['environment']
  elsif defined?(ENV['RAILS_ENV']) and !(ENV['RAILS_ENV'].nil?)
    raise RuntimeError, "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



201
202
203
# File 'lib/active_fedora.rb', line 201

def fedora
  @fedora ||= Fedora.new(fedora_config.credentials)
end

.init(options = {}) ⇒ Object



155
156
157
158
159
160
161
162
163
164
165
166
167
# File 'lib/active_fedora.rb', line 155

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!
  Predicates.predicate_config = nil
  configurator.init(options)
end

.predicate_configObject



205
206
207
# File 'lib/active_fedora.rb', line 205

def predicate_config
  configurator.predicate_config
end

.rootObject



209
210
211
# File 'lib/active_fedora.rb', line 209

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

.solrObject



197
198
199
# File 'lib/active_fedora.rb', line 197

def solr
  ActiveFedora::SolrService.instance
end

.versionObject



213
214
215
# File 'lib/active_fedora.rb', line 213

def version
  ActiveFedora::VERSION
end