Sha256: 3fb2d189ea9d9fb043e84c39fa9a0860c76c66eab48cef5e512ff7f483c42fbe
Contents?: true
Size: 1.47 KB
Versions: 39
Compression:
Stored size: 1.47 KB
Contents
module Rubydora # Copied in part from projectblacklight.org module ExtensionParameters # setup extension support 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 # try to apply registered extensions 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 # Certain class-level modules needed for the document-specific # extendability architecture module ExtendableClassMethods attr_writer :registered_extensions # registered_extensions accessor # @return [Array] def registered_extensions @registered_extensions ||= [] end # register extensions # @param [Module] module_obj # @yield &condition def use_extension( module_obj, &condition ) registered_extensions << {:module_obj => module_obj, :condition_proc => condition} end end end end
Version data entries
39 entries across 39 versions & 1 rubygems