Class: ActiveFedora::NomDatastream
Class Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#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
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
49
50
51
52
53
54
55
|
# File 'lib/active_fedora/nom_datastream.rb', line 49
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
Returns the value of attribute terminology.
17
18
19
|
# File 'lib/active_fedora/nom_datastream.rb', line 17
def terminology
@terminology
end
|
.terminology_options ⇒ Object
Returns the value of attribute terminology_options.
13
14
15
|
# File 'lib/active_fedora/nom_datastream.rb', line 13
def terminology_options
@terminology_options
end
|
Class Method Details
.decorate_ng_xml(xml) ⇒ Object
20
21
22
23
24
|
# File 'lib/active_fedora/nom_datastream.rb', line 20
def self.decorate_ng_xml(xml)
xml.set_terminology terminology_options, &terminology
xml.nom!
xml
end
|
.set_terminology(options = {}, &block) ⇒ Object
7
8
9
10
|
# File 'lib/active_fedora/nom_datastream.rb', line 7
def self.set_terminology(options = {}, &block)
@terminology_options = options || {}
@terminology = block
end
|
Instance Method Details
#respond_to?(*args) ⇒ Boolean
61
62
63
|
# File 'lib/active_fedora/nom_datastream.rb', line 61
def respond_to?(*args)
super || self.class.terminology.respond_to?(*args)
end
|
#respond_to_missing?(*args) ⇒ Boolean
57
58
59
|
# File 'lib/active_fedora/nom_datastream.rb', line 57
def respond_to_missing?(*args)
ng_xml.respond_to?(*args)
end
|
#serialize! ⇒ Object
26
27
28
|
# File 'lib/active_fedora/nom_datastream.rb', line 26
def serialize!
self.content = @ng_xml.to_s if @ng_xml
end
|
#to_solr ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/active_fedora/nom_datastream.rb', line 30
def to_solr
solr_doc = {}
ng_xml.terminology.flatten.select { |x| x.options[:index] }.each do |term|
term.values.each do |v|
Array(term.options[: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
|