Class: GalleryPhotos

Inherits:
Object
  • Object
show all
Defined in:
lib/components/gallery_photos.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent, params) ⇒ GalleryPhotos

Returns a new instance of GalleryPhotos.



5
6
7
8
# File 'lib/components/gallery_photos.rb', line 5

def initialize(parent, params)
  @parent = parent
  @params = params
end

Instance Attribute Details

#paramsObject (readonly)

Returns the value of attribute params.



3
4
5
# File 'lib/components/gallery_photos.rb', line 3

def params
  @params
end

#parentObject (readonly)

Returns the value of attribute parent.



2
3
4
# File 'lib/components/gallery_photos.rb', line 2

def parent
  @parent
end

Instance Method Details



10
11
12
13
14
# File 'lib/components/gallery_photos.rb', line 10

def sort_gallery_photos_for_parent
  params[:gallery_photos].each_with_index do |id, index|
    parent.gallery_photos.find(id).update_attributes(order: index+1)
  end
end