Module: Attachinary::FileMixin
- Included in:
- File
- Defined in:
- lib/attachinary/orm/file_mixin.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
3 4 5 6 7 8 |
# File 'lib/attachinary/orm/file_mixin.rb', line 3 def self.included(base) base.validates :public_id, :version, :resource_type, presence: true base.attr_accessible :public_id, :version, :width, :height, :format, :resource_type base.after_destroy :destroy_file base.after_create :remove_temporary_tag end |
Instance Method Details
#as_json(options) ⇒ Object
10 11 12 |
# File 'lib/attachinary/orm/file_mixin.rb', line 10 def as_json() super(only: [:id, :public_id, :format, :version, :resource_type], methods: [:path]) end |
#fullpath(options = {}) ⇒ Object
23 24 25 26 |
# File 'lib/attachinary/orm/file_mixin.rb', line 23 def fullpath(={}) format = .delete(:format) Cloudinary::Utils.cloudinary_url(path(format), ) end |
#path(custom_format = nil) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/attachinary/orm/file_mixin.rb', line 14 def path(custom_format=nil) p = "v#{version}/#{public_id}" if resource_type == 'image' && custom_format != false custom_format ||= format p<< ".#{custom_format}" end p end |