class SakaiInfo::Metaobj
Attributes
dbrow[R]
description[R]
external_type[R]
schema_hash[R]
Public Class Methods
all_serializations()
click to toggle source
# File lib/sakai-info/metaobj.rb, line 188 def self.all_serializations [ :default, :mod, :instructions, :schemadata, ] end
clear_cache()
click to toggle source
# File lib/sakai-info/metaobj.rb, line 22 def self.clear_cache @@cache = {} end
find(id)
click to toggle source
# File lib/sakai-info/metaobj.rb, line 36 def self.find(id) if @@cache[id].nil? row = DB.connect[:metaobj_form_def].filter(:id => id).first if row.nil? raise ObjectNotFoundException.new(Metaobj, id) end @@cache[id] = Metaobj.new(row) end @@cache[id] end
new(dbrow)
click to toggle source
# File lib/sakai-info/metaobj.rb, line 27 def initialize(dbrow) @dbrow = dbrow @id = dbrow[:id] @description = dbrow[:description] @external_type = dbrow[:externaltype] @schema_hash = dbrow[:schema_hash] end
Public Instance Methods
alternate_create_xslt()
click to toggle source
# File lib/sakai-info/metaobj.rb, line 103 def alternate_create_xslt if @dbrow[:alternatecreatexslt].nil? nil else @@alternate_create_xslt ||= ContentResource.find_by_uuid(@dbrow[:alternatecreatexslt]) end end
alternate_view_xslt()
click to toggle source
# File lib/sakai-info/metaobj.rb, line 111 def alternate_view_xslt if @dbrow[:alternateviewxslt].nil? nil else @@alternate_view_xslt ||= ContentResource.find_by_uuid(@dbrow[:alternateviewxslt]) end end
default_serialization()
click to toggle source
serialization
# File lib/sakai-info/metaobj.rb, line 132 def default_serialization result = { "id" => self.id, "description" => self.description, "owner" => self.owner.serialize(:summary), "site" => nil, "system_only" => self.system_only?, "published" => self.published?, "globally_published" => self.globally_published?, "pending_approval" => self.pending_approval?, "external_type" => self.external_type, "alternate_create_xslt" => nil, "alternate_view_xslt" => nil, "schema_hash" => self.schema_hash, } if self.site.nil? result.delete("site") else result["site"] = self.site.serialize(:summary) end if not self.pending_approval? result.delete("pending_approval") end if self.alternate_create_xslt.nil? result.delete("alternate_create_xslt") else result["alternate_create_xslt"] = self.alternate_create_xslt.serialize(:summary) end if self.alternate_view_xslt.nil? result.delete("alternate_view_xslt") else result["alternate_view_xslt"] = self.alternate_view_xslt.serialize(:summary) end result end
global_state()
click to toggle source
# File lib/sakai-info/metaobj.rb, line 82 def global_state case @dbrow[:globalstate] when 0 "unpublished" when 1 "pending approval" when 2 "published" else @dbrow[:globalstate] end end
globally_published?()
click to toggle source
# File lib/sakai-info/metaobj.rb, line 95 def globally_published? self.global_state == "published" end
instructions()
click to toggle source
# File lib/sakai-info/metaobj.rb, line 119 def instructions if @dbrow[:instructions].nil? nil else @instructions ||= @dbrow[:instruction].read end end
instructions_serialization()
click to toggle source
# File lib/sakai-info/metaobj.rb, line 176 def instructions_serialization { "instructions" => self.instructions, } end
owner()
click to toggle source
# File lib/sakai-info/metaobj.rb, line 47 def owner @owner ||= User.find(@dbrow[:owner]) end
pending_approval?()
click to toggle source
# File lib/sakai-info/metaobj.rb, line 99 def pending_approval? self.global_state == "pending approval" end
published?()
click to toggle source
# File lib/sakai-info/metaobj.rb, line 78 def published? self.site_state == "published" end
schemadata()
click to toggle source
# File lib/sakai-info/metaobj.rb, line 127 def schemadata @schemadata ||= @dbrow[:schemadata].read.force_encoding(Encoding::UTF_8) end
schemadata_serialization()
click to toggle source
# File lib/sakai-info/metaobj.rb, line 182 def schemadata_serialization { "schemadata" => self.schemadata, } end
site()
click to toggle source
# File lib/sakai-info/metaobj.rb, line 55 def site if @dbrow[:siteid] begin @site ||= Site.find(@dbrow[:siteid]) rescue ObjectNotFoundException nil end else nil end end
site_state()
click to toggle source
# File lib/sakai-info/metaobj.rb, line 67 def site_state case @dbrow[:sitestate] when 0 "unpublished" when 2 "published" else @dbrow[:sitestate] end end
summary_serialization()
click to toggle source
# File lib/sakai-info/metaobj.rb, line 168 def summary_serialization { "id" => self.id, "description" => self.description, "owner" => self.owner.eid, } end
system_only?()
click to toggle source
# File lib/sakai-info/metaobj.rb, line 51 def system_only? @dbrow[:systemonly] == 1 end