class Atompub::ServiceInfoStorage

Public Class Methods

instance() click to toggle source
# File lib/atomutil.rb, line 1249
def self.instance
  @@singleton = self.new if @@singleton.nil?
  @@singleton
end
new() click to toggle source
# File lib/atomutil.rb, line 1254
def initialize
  @info = Hash.new
end

Public Instance Methods

get(uri) click to toggle source
# File lib/atomutil.rb, line 1258
def get(uri)
  @info.has_key?(uri) ? @info[uri] : nil
end
put(uri, collection, client=nil) click to toggle source
# File lib/atomutil.rb, line 1262
def put(uri, collection, client=nil)
  new_collection = clone_collection(collection, client)
  @info[uri] = ServiceInfo.new(:collection => new_collection)
end

Private Instance Methods

clone_categories(categories) click to toggle source
# File lib/atomutil.rb, line 1286
def clone_categories(categories)
  cats = Atom::Categories.new
  cats.fixed  = categories.fixed
  cats.scheme = categories.scheme
  categories.categories.each do |c|
    new_c = Atom::Category.new
    new_c.term = c.term
    new_c.scheme = c.scheme
    new_c.label = c.label
    cats.add_category new_c
  end
  cats
end
clone_collection(collection, client=nil) click to toggle source
# File lib/atomutil.rb, line 1268
def clone_collection(collection, client=nil)
  coll = Atom::Collection.new
  coll.title = collection.title
  coll.href  = collection.href
  collection.accepts.each { |a| coll.add_accept a.text }
  collection.categories_list.each do |cats|
    unless cats.nil?
      new_cats = cats.href.nil?? clone_categories(cats) : get_categories(cats.href, client)
      coll.categories = new_cats unless new_cats.nil?
    end
  end
  coll
end
get_categories(uri, client=nil) click to toggle source
# File lib/atomutil.rb, line 1282
def get_categories(uri, client=nil)
  client.nil?? nil : client.get_categories(uri)
end