Module: PagesCore::PageModel::Images

Extended by:
ActiveSupport::Concern
Included in:
Page
Defined in:
app/models/concerns/pages_core/page_model/images.rb

Instance Method Summary collapse

Instance Method Details

#imageObject



33
34
35
# File 'app/models/concerns/pages_core/page_model/images.rb', line 33

def image
  super.try { |i| i.localize(locale) }
end

#image?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'app/models/concerns/pages_core/page_model/images.rb', line 29

def image?
  image_id?
end

#imagesObject



37
38
39
# File 'app/models/concerns/pages_core/page_model/images.rb', line 37

def images
  super.in_locale(locale)
end

#page_imagesObject



41
42
43
# File 'app/models/concerns/pages_core/page_model/images.rb', line 41

def page_images
  super.in_locale(locale)
end

#page_images_attributes=(attrs) ⇒ Object



45
46
47
48
# File 'app/models/concerns/pages_core/page_model/images.rb', line 45

def page_images_attributes=(attrs)
  ids = page_images.map(&:id)
  super(attrs.reject { |a| a["_destroy"] && ids.exclude?(a["id"]) })
end