Module: Exlibris::Primo::Pnx::Elements
- Included in:
- Record
- Defined in:
- lib/exlibris/primo/pnx/elements.rb
Overview
Provides access to PNX elements
Instance Method Summary collapse
-
#method_missing(method, *args, &block) ⇒ Object
Parses elements from PNX base on the pattern parentname_childname e.g.
-
#respond_to?(method, include_private = false) ⇒ Boolean
Tell user we respond to PNX elements.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
Parses elements from PNX base on the pattern parentname_childname e.g.
record.display_title #=> "Travels with my aunt"
based on the XML
<record>
...
<display>
...
<title>Travels with my aunt</title>
...
</display>
...
</record>
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/exlibris/primo/pnx/elements.rb', line 23 def method_missing(method, *args, &block) if(attr_read(method)) self.class.send(:define_method, method) { if "#{method}".start_with? "all_" eval("@#{method} ||= #{attr_read(method).inspect}") else eval("@#{method} ||= #{attr_read(method).inspect}") end } send method, *args, &block else super end end |
Instance Method Details
#respond_to?(method, include_private = false) ⇒ Boolean
Tell user we respond to PNX elements
41 42 43 |
# File 'lib/exlibris/primo/pnx/elements.rb', line 41 def respond_to?(method, include_private=false) (attr_read(method)) ? true : super end |