Sha256: 7e027588fb1d34e00384d453866e837b40cdc8295e1ddada1ceb03031b5e06a5

Contents?: true

Size: 805 Bytes

Versions: 2

Compression:

Stored size: 805 Bytes

Contents

module RailsGallery
  module ViewHelper
    def self.galleries
      %w{galleria responsive slideshow}
    end

    # autoload all galleries when references
    galleries.each do |gallery|
      autoload gallery.camelize.to_sym, "rails-gallery/view_helper/#{gallery}"
    end

    def gallery_image type, photo
      meth_name = "#{type}_gallery_image"
      unless respond_to? meth_name
        raise ArgumentError, "Gallery #{type} is not yet supported. Please add a View helper module for this gallery using the convention followed by the other galleries..." 
      end
      send(meth_name, photo)
    end

    protected

    # include view helper modules for all galleries :)
    galleries.each do |gallery|
      include "RailsGallery::ViewHelper::#{gallery.camelize}".constantize
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rails-gallery-0.2.1 lib/rails-gallery/view_helper.rb
rails-gallery-0.2.0 lib/rails-gallery/view_helper.rb