Sha256: ea28bad1be770630c65558eebde087ef025eaf17a751581be0260d1c18497e55

Contents?: true

Size: 838 Bytes

Versions: 14

Compression:

Stored size: 838 Bytes

Contents

module ModsDisplay
  module 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
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
mods_display-0.10.1 lib/mods_display/controller_extension.rb
mods_display-0.10.0 lib/mods_display/controller_extension.rb
mods_display-0.9.1 lib/mods_display/controller_extension.rb
mods_display-0.9.0 lib/mods_display/controller_extension.rb
mods_display-0.8.0 lib/mods_display/controller_extension.rb
mods_display-0.7.1 lib/mods_display/controller_extension.rb
mods_display-0.7.0 lib/mods_display/controller_extension.rb
mods_display-0.6.0 lib/mods_display/controller_extension.rb
mods_display-0.5.1 lib/mods_display/controller_extension.rb
mods_display-0.5.0 lib/mods_display/controller_extension.rb
mods_display-0.4.1 lib/mods_display/controller_extension.rb
mods_display-0.4.0 lib/mods_display/controller_extension.rb
mods_display-0.3.5 lib/mods_display/controller_extension.rb
mods_display-0.3.4 lib/mods_display/controller_extension.rb