Module: ActiveadminSettings::PictureMethods

Included in:
Picture
Defined in:
app/models/activeadmin_settings/picture.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



4
5
6
7
# File 'app/models/activeadmin_settings/picture.rb', line 4

def self.included(base)
  # Features
  base.mount_uploader :data, ActiveadminSettings::RedactorPictureUploader
end

Instance Method Details

#as_json(options = nil) ⇒ Object



34
35
36
37
38
39
# File 'app/models/activeadmin_settings/picture.rb', line 34

def as_json(options = nil)
  options = {
    :methods => as_json_methods
  }
  super options
end

#as_json_methodsObject



30
31
32
# File 'app/models/activeadmin_settings/picture.rb', line 30

def as_json_methods
  [:image, :thumb]
end

#has_dimensions?Boolean

Helpers

Returns:

  • (Boolean)


10
11
12
# File 'app/models/activeadmin_settings/picture.rb', line 10

def has_dimensions?
  respond_to?(:width) && respond_to?(:height)
end

#imageObject



22
23
24
# File 'app/models/activeadmin_settings/picture.rb', line 22

def image
  url
end

#image?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'app/models/activeadmin_settings/picture.rb', line 14

def image?
  ActiveadminSettings::IMAGE_TYPES.include?(data_content_type)
end

#thumbObject



26
27
28
# File 'app/models/activeadmin_settings/picture.rb', line 26

def thumb
  data.thumb.url
end

#urlObject



18
19
20
# File 'app/models/activeadmin_settings/picture.rb', line 18

def url
  data.url
end