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

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

Instance Method Summary collapse

Instance Method Details

#content_type(content_type) ⇒ Object


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

def content_type(content_type)
  return nil unless @supported_types.present?

  @supported_types[content_type]
end

#file_through(content_types) ⇒ Object


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

def file_through(content_types)
  content_type(content_types.detect do |ct|
    content_type(ct)
  end)
end

#has_file(options) ⇒ Object


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

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