Class: Attachment
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Attachment
- Defined in:
- app/models/attachment.rb
Class Method Summary collapse
-
.attrs ⇒ Object
Returns attributes attached to the attachment.
-
.methds ⇒ Object
Returns methods with usefuly information.
-
.params ⇒ Object
Returns a custom hash of attributes on the product.
Instance Method Summary collapse
- #caption(*params) ⇒ Object
- #title(*params) ⇒ Object
-
#to_json(*attrs) ⇒ Object
Overloads the base to_json to return what we want.
- #url(*params) ⇒ Object
Class Method Details
.attrs ⇒ Object
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 |
.methds ⇒ Object
Returns methods with usefuly information
38 39 40 |
# File 'app/models/attachment.rb', line 38 def methds [ :url, :title, :caption ] end |
.params ⇒ Object
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 (*params) image.(*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 |