Module: Rubydora::ExtensionParameters

Included in:
Datastream, DigitalObject
Defined in:
lib/rubydora/extension_parameters.rb

Overview

Copied in part from projectblacklight.org

Defined Under Namespace

Modules: ExtendableClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object

setup extension support



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/rubydora/extension_parameters.rb', line 5

def self.included(base)
  base.extend ExtendableClassMethods

  base.class_eval do
    # Provide a class-level hash for extension parameters
    # @return [Hash]
    def self.extension_parameters
      ## This variable should NOT be @@, since we're in a class method,
      # it's just @ to be a class variable. Confusing, but it
      # passes the tests this way.       
      @extension_parameters ||= {}
    end      
  end

  base.after_initialize do
    apply_extensions
  end
end

Instance Method Details

#apply_extensionsObject

try to apply registered extensions



25
26
27
28
29
# File 'lib/rubydora/extension_parameters.rb', line 25

def apply_extensions
  self.class.registered_extensions.each do |registration|
    self.extend( registration[:module_obj] ) if registration[:condition_proc].nil? || registration[:condition_proc].call( self )
  end
end