Class: Cul::Hydra::Om::StandardMods

Inherits:
ActiveFedora::OmDatastream
  • Object
show all
Defined in:
lib/cul_hydra/om/standard_mods.rb

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/cul_hydra/om/standard_mods.rb', line 86

def method_missing method, *args
  query = false
  _mname = method.id2name
  if _mname[-1,1] == '?'
    query = true
    _mname = _mname[0,_mname.length-1]
  end
  _msym = _mname.to_sym
  begin
    has_term = self.class.terminology.has_term?(_msym)

    _r = (has_term)? find_by_terms(_msym, *args) : nil
    if query
      return !( _r.nil? || _r.size()==0)
    else
      return _r
    end
  rescue
    super
  end
end

Class Method Details

.xml_templateObject



67
68
69
70
71
72
73
74
75
76
77
# File 'lib/cul_hydra/om/standard_mods.rb', line 67

def self.xml_template
  builder = Nokogiri::XML::Builder.new do |xml|
    xml.mods(:version=>"3.4",
       "xmlns"=>"http://www.loc.gov/mods/v3",
       "xmlns:xsi"=>"http://www.w3.org/2001/XMLSchema-instance"){
    }
  end
  builder.doc.encoding = 'UTF-8'
  builder.doc.root["xsi:schemaLocation"] = 'http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-4.xsd'
  return builder.doc
end

Instance Method Details

#prefixObject



79
80
81
82
83
84
# File 'lib/cul_hydra/om/standard_mods.rb', line 79

def prefix
  #if ::ActiveFedora::VERSION >= '8'
  #  Rails.logger.warn("the prefix method of #{self.class.name} was overriden to maintain backwards compatibility")
  #end
  ''
end

#update_values(params) ⇒ Object



107
108
109
110
# File 'lib/cul_hydra/om/standard_mods.rb', line 107

def update_values(params)
  super
  self.dirty = true
end