Module: Bulldog::Attachment

Defined in:
lib/bulldog/attachment.rb,
lib/bulldog/attachment.rb,
lib/bulldog/attachment/pdf.rb,
lib/bulldog/attachment/base.rb,
lib/bulldog/attachment/none.rb,
lib/bulldog/attachment/image.rb,
lib/bulldog/attachment/maybe.rb,
lib/bulldog/attachment/video.rb,
lib/bulldog/attachment/unknown.rb,
lib/bulldog/attachment/has_dimensions.rb

Defined Under Namespace

Modules: HasDimensions Classes: Base, Image, Maybe, None, Pdf, Unknown, Video

Class Method Summary collapse

Class Method Details

.class_from_type(type) ⇒ Object

Return the class corresponding to the given type.



45
46
47
# File 'lib/bulldog/attachment.rb', line 45

def self.class_from_type(type)
  types_to_classes[type]
end

.none(record, name) ⇒ Object

Return a None attachment for the given record and name.



38
39
40
# File 'lib/bulldog/attachment.rb', line 38

def self.none(record, name)
  None.new(record, name, nil)
end

.of_type(type, record, name, stream) ⇒ Object

Return a new attachment of the specified type.

If type is nil, then the returned attachment will be None if the stream is nil, or Unknown otherwise.



26
27
28
29
30
31
32
33
# File 'lib/bulldog/attachment.rb', line 26

def self.of_type(type, record, name, stream)
  if type.nil?
    klass = stream ? Unknown : None
  else
    klass = class_from_type(type)
  end
  klass.new(record, name, stream)
end

.types_to_classesObject

:nodoc:



3
4
5
# File 'lib/bulldog/attachment.rb', line 3

def self.types_to_classes  #:nodoc:
  @types_to_classes ||= {}
end