Module: Exlibris::Primo::Pnx::DedupMgr

Included in:
Record
Defined in:
lib/exlibris/primo/pnx/dedup_mgr.rb

Overview

Handle PNX dedupmgr elements

Defined Under Namespace

Modules: ClassAttributes

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, &block) ⇒ Object

Dynamically set the duplicated control attributes.



54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/exlibris/primo/pnx/dedup_mgr.rb', line 54

def method_missing(method, *args, &block)
  if(duplicated_control_attributes.include? method)
    control_attribute = method.id2name.singularize
    self.class.send(:define_method, method) do
      eval("@#{method} ||= (dedupmgr?) ?
        map_values_to_origins(\"#{control_attribute}\") : {recordid => #{control_attribute}}")
    end
    send method, *args, &block
  else
    super
  end
end

Class Method Details

.included(klass) ⇒ Object



9
10
11
12
13
# File 'lib/exlibris/primo/pnx/dedup_mgr.rb', line 9

def self.included(klass)
  klass.class_eval do
    extend ClassAttributes
  end
end

Instance Method Details

#dedupmgr?Boolean

Is the record a dedupmrg record?

Returns:

  • (Boolean)


39
40
41
# File 'lib/exlibris/primo/pnx/dedup_mgr.rb', line 39

def dedupmgr?
  @dedupmgr ||= recordid.match /\Adedupmrg/
end

#respond_to?(method, include_private = false) ⇒ Boolean

Tell users we respond to pluralized PNX control elements

Returns:

  • (Boolean)


70
71
72
# File 'lib/exlibris/primo/pnx/dedup_mgr.rb', line 70

def respond_to?(method, include_private=false)
  (duplicated_control_attributes.include? method) ? true : super
end