Module: Polygallery::ActsAsPolyphoto::LocalInstanceMethods

Defined in:
app/models/concerns/polygallery/acts_as_polyphoto.rb

Instance Method Summary collapse

Instance Method Details

#include_polygallery_settings(settings) ⇒ Object



53
54
55
56
# File 'app/models/concerns/polygallery/acts_as_polyphoto.rb', line 53

def include_polygallery_settings(settings)
  self.polygallery_options = settings
  self.initialize_polyphoto
end

#init_attachmentObject



109
110
111
# File 'app/models/concerns/polygallery/acts_as_polyphoto.rb', line 109

def init_attachment
  self.class.init_attachment paperclip_settings
end

#initialize_polyphotoObject



58
59
60
61
# File 'app/models/concerns/polygallery/acts_as_polyphoto.rb', line 58

def initialize_polyphoto
  self.class.init_associations(self.polygallery_settings)
  self.init_attachment
end

#paperclip_settingsObject



95
96
97
# File 'app/models/concerns/polygallery/acts_as_polyphoto.rb', line 95

def paperclip_settings
  self.polygallery_settings[:paperclip]
end

#polygallery_settingsObject



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'app/models/concerns/polygallery/acts_as_polyphoto.rb', line 63

def polygallery_settings
  return self.polygallery_options if self.polygallery_options.present?
  if self.gallery_title.present?
    s = if self.galleryable.present?
          galleryable.class.send(:"#{self.gallery_title}_settings")
        elsif self.galleryable_type.present?
          Kernel.const_get(self.galleryable_type)
            .send(:"#{self.gallery_title}_settings")
        end
    return s if s.present?
  # elsif respond_to?(:gallery) && gallery.present?
  #   return gallery.polygallery_settings
  # elsif self.gallery_id.present?
  #   g = Kernel.const_get(self.galleryable_type).find(self.gallery_id)
  #   if g.present?
  #     self.gallery_title = g.title
  #     return self.polygallery_settings
  #   end
  end
  self.class.polygallery_settings
  # if gallery_title.present? && galleryable_type.present?
  #   galleryable_class = Kernel.const_get(galleryable_type)
  #   galleryable_class.send :"#{gallery_title}_settings"
  # elsif gallery_title.present?
  #   self.send(gallery_title.to_sym).polygallery_settings
  # elsif self.gallery.present? && gallery.polygallery_settings.present?
  #   self.gallery.polygallery_settings 
  # else
  #   HasPolygallery::DEFAULTS
  # end
end

#process_photo_to_uploadObject



99
100
101
102
103
104
105
106
107
# File 'app/models/concerns/polygallery/acts_as_polyphoto.rb', line 99

def process_photo_to_upload
  if self.photo.present? && self.photo_to_upload.nil?
    if self.new_record? || self.photo_file_name_changed?
      self.photo_to_upload = self.photo.staged_path
      self.photo = nil
    end
  end
  self.photo = File.open(photo_to_upload) if photo_to_upload.present?
end