Class: Attachment

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/attachment.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.attrsObject

Returns attributes attached to the attachment



33
34
35
# File 'app/models/attachment.rb', line 33

def attrs
  [ :id, :title, :caption, :image_file_name, :image_content_type, :image_file_size ]
end

.methdsObject

Returns methods with usefuly information



38
39
40
# File 'app/models/attachment.rb', line 38

def methds
  [ :url, :title, :caption ]
end

.paramsObject

Returns a custom hash of attributes on the product



43
44
45
# File 'app/models/attachment.rb', line 43

def params
  { :only  => self.attrs, :methods => self.methds }
end

Instance Method Details

#caption(*params) ⇒ Object



23
24
25
# File 'app/models/attachment.rb', line 23

def caption(*params)
  image.caption(*params) rescue nil
end

#title(*params) ⇒ Object



19
20
21
# File 'app/models/attachment.rb', line 19

def title(*params)
  image.title(*params) rescue nil
end

#to_json(*attrs) ⇒ Object

Overloads the base to_json to return what we want



28
# File 'app/models/attachment.rb', line 28

def to_json(*attrs); super self.class.params; end

#url(*params) ⇒ Object



15
16
17
# File 'app/models/attachment.rb', line 15

def url(*params)
  image.url(*params) rescue nil
end