Sha256: 0b5d564af242dcc3d499c83761dbb8b7d7387973647ce13b5cdf631c83c08d3d

Contents?: true

Size: 773 Bytes

Versions: 10

Compression:

Stored size: 773 Bytes

Contents

module ModsDisplay::ControllerExtension

  def self.included(base)
    base.extend ClassMethods
    base.class_eval do
      def mods_display_config
        @mods_display_config || self.class.mods_display_config
      end
      if base.respond_to?(:helper_method)
        helper_method :mods_display_config, :render_mods_display
      end
    end
  end

  def render_mods_display model
    return "" if model.mods_display_xml.nil?
    ModsDisplay::HTML.new(mods_display_config, model.mods_display_xml, self)
  end

  private

  module ClassMethods
    def configure_mods_display &config
      @mods_display_config = ModsDisplay::Configuration.new &config
    end

    def mods_display_config
      @mods_display_config || ModsDisplay::Configuration.new{}
    end
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
mods_display-0.3.3 lib/mods_display/controller_extension.rb
mods_display-0.3.2 lib/mods_display/controller_extension.rb
mods_display-0.3.1 lib/mods_display/controller_extension.rb
mods_display-0.3.0 lib/mods_display/controller_extension.rb
mods_display-0.2.4 lib/mods_display/controller_extension.rb
mods_display-0.2.3 lib/mods_display/controller_extension.rb
mods_display-0.2.2 lib/mods_display/controller_extension.rb
mods_display-0.2.1 lib/mods_display/controller_extension.rb
mods_display-0.2.0 lib/mods_display/controller_extension.rb
mods_display-0.1.4 lib/mods_display/controller_extension.rb