Sha256: 262247c9e925f98fa6fb80ff0b9606a31fda119286c1754e426bd2f31479fcaa

Contents?: true

Size: 1.13 KB

Versions: 6

Compression:

Stored size: 1.13 KB

Contents

module Enjoy::Gallery::LoadGalleryImages
  extend ActiveSupport::Concern


  def enjoy_gallery_render_gallery
    @gallery = enjoy_gallery_load_gallery
    @gallery_images = enjoy_gallery_gallery_load_images

    @next_page = (params[:page] || 1).to_i + 1

    render_opts = {
      layout:   enjoy_gallery_gallery_layout,
      action:   enjoy_gallery_gallery_action,
      partial:  enjoy_gallery_gallery_partial
    }
    render render_opts.compact
  end

  private


  def enjoy_gallery_gallery_layout
    request.xhr? ? false : 'application'
  end

  def enjoy_gallery_gallery_action
    'enjoy_gallery_render_gallery'
  end

  def enjoy_gallery_gallery_partial
    nil
  end

  def enjoy_gallery_gallery_class
    Enjoy::Gallery::Gallery
  end

  def enjoy_gallery_gallery_images_method
    :images
  end

  def enjoy_gallery_load_gallery
    enjoy_gallery_gallery_class.find(params[:gallery_id])
  end

  def enjoy_gallery_gallery_load_images
    @gallery.send(enjoy_gallery_gallery_images_method).enabled.sorted.page(params[:page]).per(enjoy_gallery_render_gallery_images_per_page)
  end

  def enjoy_gallery_gallery_per_page
    4
  end


end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
enjoy_cms_gallery-0.4.1 app/controllers/concerns/enjoy/gallery/load_gallery.rb
enjoy_cms_gallery-0.4.0.2 app/controllers/concerns/enjoy/gallery/load_gallery.rb
enjoy_cms_gallery-0.4.0.1 app/controllers/concerns/enjoy/gallery/load_gallery.rb
enjoy_cms_gallery-0.4.0 app/controllers/concerns/enjoy/gallery/load_gallery.rb
enjoy_cms_gallery-0.4.0.beta3 app/controllers/concerns/enjoy/gallery/load_gallery.rb
enjoy_cms_gallery-0.4.0.beta1 app/controllers/concerns/enjoy/gallery/load_gallery.rb