class Atompub::ServiceInfo
Public Class Methods
new(params)
click to toggle source
# File lib/atomutil.rb, line 1206 def initialize(params) @collection = params[:collection] @allowed_categories = nil @accepts = nil end
Public Instance Methods
accepts_media_type?(content_type)
click to toggle source
# File lib/atomutil.rb, line 1231 def accepts_media_type?(content_type) return true if @collection.nil? if @accepts.nil? @accepts = @collection.accepts.collect do |accept| accept.text.split(/[\s,]+/) end.flatten @accepts << Atom::MediaType::ENTRY if @accepts.empty? end type = Atom::MediaType.new(content_type) @accepts.any?{ |a| type.is_a?(a) } end
allows_category?(test)
click to toggle source
# File lib/atomutil.rb, line 1212 def allows_category?(test) return true if @collection.nil? categories_list = @collection.categories_list return true if categories_list.empty? return true if categories_list.all? { |cats| cats.fixed.nil? || cats.fixed != 'yes' } if @allowed_categories.nil? @allowed_categories = categories_list.collect do |cats| cats.categories.collect do |cat| scheme = cat.scheme || cats.scheme || nil new_cat = Atom::Category.new :term => cat.term new_cat.scheme = scheme unless scheme.nil? new_cat end end.flatten end return false if @allowed_categories.empty? @allowed_categories.any?{ |c| c.term == test.term && (c.scheme.nil? || (!c.scheme.nil? && c.scheme == test.scheme )) } end