Class: Refile::Type

Inherits:
Object
  • Object
show all
Defined in:
lib/refile/type.rb

Overview

A type represents an alias for one or multiple content types. By adding types, you could simplify this:

attachment :document, content_type: %w[text/plain application/pdf]

To this:

attachment :document, type: :document

Simply define a new type like this:

Refile.types[:document] = Refile::Type.new(:document,
  content_type: %w[text/plain application/pdf]
)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, content_type: nil) ⇒ Type

Returns a new instance of Type.

Parameters:

  • name (Symbol)

    the name of the type

  • content_type (String, Array<String>) (defaults to: nil)

    content types which are valid for this type



23
24
25
26
# File 'lib/refile/type.rb', line 23

def initialize(name, content_type: nil)
  @name = name
  @content_type = content_type
end

Instance Attribute Details

#content_typeString+

Returns The type’s content types.

Returns:

  • (String, Array<String>)

    The type’s content types



19
20
21
# File 'lib/refile/type.rb', line 19

def content_type
  @content_type
end