Module: CubaApi::AcceptContent::ClassMethods

Defined in:
lib/cuba_api/accept_content.rb

Constant Summary collapse

MIMES =
{ :yaml => ['application/x-yaml', 'text/yaml'],
:json => ['application/json'],
:xml => ['application/xml'] }

Instance Method Summary collapse

Instance Method Details

#accept(*args) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/cuba_api/accept_content.rb', line 31

def accept( *args )
  args.each do |arg|
    (MIMES[ arg ] || []).each do |mime|
      if arg == :yaml
        require 'safe_yaml' unless defined?( YAML )
      end
      mimes[ mime ] = "to_#{arg}".to_sym
    end
  end
  warn "[CubaAPI] Accept: #{mimes.keys.join(', ')}"
end

#mimesObject



43
44
45
# File 'lib/cuba_api/accept_content.rb', line 43

def mimes
  self[ :mimes ] ||= {}
end