Method: RDF::Format.content_type
- Defined in:
- lib/rdf/format.rb
.content_type(type, options) ⇒ void .content_type ⇒ Array<String>
Retrieves or defines MIME content types for this RDF serialization format.
497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 |
# File 'lib/rdf/format.rb', line 497 def self.content_type(type = nil, = {}) if type.nil? [@@content_type[self], @@content_types.map { |ct, cl| (cl.include?(self) && ct != @@content_type[self]) ? ct : nil }].flatten.compact else accept_type, type = type, type.split(';').first @@content_type[self] = type @@content_types[type] ||= [] @@content_types[type] << self unless @@content_types[type].include?(self) @@accept_types[accept_type] ||= [] @@accept_types[accept_type] << self unless @@accept_types[accept_type].include?(self) if extensions = ([:extension] || [:extensions]) extensions = Array(extensions).map(&:to_sym) extensions.each do |ext| @@file_extensions[ext] ||= [] @@file_extensions[ext] << self unless @@file_extensions[ext].include?(self) end end if aliases = ([:alias] || [:aliases]) aliases = Array(aliases).each do |a| aa = a.split(';').first @@accept_types[a] ||= [] @@accept_types[a] << self unless @@accept_types[a].include?(self) @@content_types[aa] ||= [] @@content_types[aa] << self unless @@content_types[aa].include?(self) end end # URI identifying this format if uri = [:uri] @@uris[RDF::URI(uri)] = self end end end |