Class: Shoppe::Attachment

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.for(role) ⇒ Object

Return the attachment for a given role



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

def self.for(role)
  self.where(role: role).first
end

Instance Method Details

#image?Boolean

Is the attachment an image?

Returns:

  • (Boolean)


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

def image?
  file_type.match(/\Aimage\//).present?
end

#pathObject

Return the path to the attachment



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

def path
  file.url
end