Module: Core::Endpoint::BasicHandler::Associations::HasFile

Included in:
Core::Endpoint::BasicHandler
Defined in:
app/api/core/endpoint/basic_handler/associations/has_file.rb

Overview

rubocop:todo Style/Documentation

Instance Method Summary collapse

Instance Method Details

#content_type(content_type) ⇒ Object


9
10
11
12
13
# File 'app/api/core/endpoint/basic_handler/associations/has_file.rb', line 9

def content_type(content_type)
  return nil if @supported_types.blank?

  @supported_types[content_type]
end

#file_through(content_types) ⇒ Object


15
16
17
# File 'app/api/core/endpoint/basic_handler/associations/has_file.rb', line 15

def file_through(content_types)
  content_type(content_types.detect { |ct| content_type(ct) })
end

#has_file(options) ⇒ Object


3
4
5
6
7
# File 'app/api/core/endpoint/basic_handler/associations/has_file.rb', line 3

def has_file(options)
  ::Api::EndpointHandler.register_mimetype(options[:content_type])
  @supported_types ||= {}
  @supported_types[options[:content_type]] = options[:as] || :retrieve_file
end