Class: ActiveFedora::NomDatastream
- Extended by:
- Deprecation
- Includes:
- Datastreams::NokogiriDatastreams
- Defined in:
- lib/active_fedora/nom_datastream.rb
Constant Summary
Constants included from AttributeMethods
AttributeMethods::AttrNames, AttributeMethods::BLACKLISTED_CLASS_METHODS
Constants included from Callbacks
Class Attribute Summary collapse
-
.terminology ⇒ Object
readonly
Returns the value of attribute terminology.
-
.terminology_options ⇒ Object
readonly
Returns the value of attribute terminology_options.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(*args) ⇒ NomDatastream
constructor
A new instance of NomDatastream.
- #method_missing(method, *args, &block) ⇒ Object
- #respond_to?(*args) ⇒ Boolean
- #serialize! ⇒ Object
- #to_solr ⇒ Object
Methods included from Datastreams::NokogiriDatastreams
#autocreate?, #content, #content=, #content_changed?, #ng_xml, #ng_xml=, #ng_xml_changed?, #ng_xml_doesnt_change!, #ng_xml_will_change!, #refresh_attributes, #remote_content, #to_xml, #xml_loaded
Methods inherited from File
#attribute_will_change!, #changed?, #check_fixity, #checksum, #content, #content=, #content_changed?, #datastream_will_change!, #described_by, #exists!, #inspect, #ldp_connection, #metadata, #metadata?, #metadata_changed?, #new_record?, #refresh, #reload, #remote_content, #uri=
Methods included from Querying
#default_sort_params, extended
Methods included from Scoping
#initialize_internals_callback, #populate_with_current_scope_attributes
Methods included from Identifiable
Methods included from AttributeMethods
#[], #[]=, #attribute_for_inspect, #attribute_names, #attribute_present?, #attributes, #has_attribute?
Methods included from Callbacks
Methods included from Versionable
#create_version, #has_versions?, #model_type, #restore_version, #versions
Methods included from Persistence
#base_path_for_resource=, #delete, #destroy, #destroy!, #destroyed?, #eradicate, #new_record?, #persisted?, #save, #save!, #update
Methods included from File::Streaming
Methods included from File::Attributes
#assign_attributes, #create_date, #digest, #dirty_size, #empty?, #has_content?, #mime_type, #original_name, #original_name=, #persisted_size, #size
Methods included from Common
#<=>, #==, #freeze, #frozen?, #ldp_source, #readonly!, #readonly?
Constructor Details
#initialize(*args) ⇒ NomDatastream
Returns a new instance of NomDatastream.
13 14 15 16 |
# File 'lib/active_fedora/nom_datastream.rb', line 13 def initialize(*args) super Deprecation.warn(NomDatastream, "NomDatastream is deprecated and will be removed in ActiveFedora 11") end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/active_fedora/nom_datastream.rb', line 55 def method_missing(method, *args, &block) if ng_xml.respond_to? method ng_xml.send(method, *args, &block) else super end end |
Class Attribute Details
.terminology ⇒ Object (readonly)
Returns the value of attribute terminology.
23 24 25 |
# File 'lib/active_fedora/nom_datastream.rb', line 23 def terminology @terminology end |
.terminology_options ⇒ Object (readonly)
Returns the value of attribute terminology_options.
19 20 21 |
# File 'lib/active_fedora/nom_datastream.rb', line 19 def @terminology_options end |
Class Method Details
.decorate_ng_xml(xml) ⇒ Object
26 27 28 29 30 |
# File 'lib/active_fedora/nom_datastream.rb', line 26 def self.decorate_ng_xml(xml) xml.set_terminology , &terminology xml.nom! xml end |
.set_terminology(options = {}, &block) ⇒ Object
8 9 10 11 |
# File 'lib/active_fedora/nom_datastream.rb', line 8 def self.set_terminology( = {}, &block) @terminology_options = || {} @terminology = block end |
Instance Method Details
#respond_to?(*args) ⇒ Boolean
63 64 65 |
# File 'lib/active_fedora/nom_datastream.rb', line 63 def respond_to?(*args) super || self.class.terminology.respond_to?(*args) end |
#serialize! ⇒ Object
32 33 34 |
# File 'lib/active_fedora/nom_datastream.rb', line 32 def serialize! self.content = @ng_xml.to_s if @ng_xml end |
#to_solr ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/active_fedora/nom_datastream.rb', line 36 def to_solr solr_doc = {} ng_xml.terminology.flatten.select { |x| x.[:index] }.each do |term| term.values.each do |v| Array(term.[:index]).each do |index_as| solr_doc[index_as] ||= [] solr_doc[index_as] << if v.is_a? Nokogiri::XML::Node v.text else v end end end end solr_doc end |