Module: GtkAttributes

Included in:
DrbDb
Defined in:
lib/DrbDB/GtkAttributes.rb

Overview

this file is part of manqod manqod is distributed under the CDDL licence the owner of manqod is Dobai-Pataky Balint([email protected])

Instance Method Summary collapse

Instance Method Details

#gtk_attribute(gtk_attr, context = self) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/DrbDB/GtkAttributes.rb', line 19

def gtk_attribute(gtk_attr, context=self)

	got=case context.class.name
		when "DrbListModel" then "list"
		when "DrbForm" then "form"
		else edebug("unsupported class in gtk_attributes: #{context.class.name} for #{context}")
	end

	(@gtk_attributes.has_key?(context.get_id.to_s) ? 
		( (@gtk_attributes[context.get_id.to_s].has_key?(got)) ? 
			@gtk_attributes[context.get_id.to_s][got][gtk_attr] : nil) : nil )
end

#gtk_attribute_of_object(gtk_attr, gtkobject_id, gtkobject_type) ⇒ Object



32
33
34
35
36
# File 'lib/DrbDB/GtkAttributes.rb', line 32

def gtk_attribute_of_object(gtk_attr,gtkobject_id,gtkobject_type)
	(@gtk_attributes.has_key?(gtkobject_id.to_s) ? 
		( (@gtk_attributes[gtkobject_id.to_s].has_key?(gtkobject_type)) ? 
			@gtk_attributes[gtkobject_id.to_s][gtkobject_type][gtk_attr] : nil) : nil )
end

#load_all_attributesObject



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/DrbDB/GtkAttributes.rb', line 6

def load_all_attributes
	@gtk_attributes=Hash.new
	cnt=0
	admin.rows("select * from gtkattributes").each{|row|
		@gtk_attributes[row["gtkobjectid"]]=Hash.new unless @gtk_attributes.has_key?(row["gtkobjectid"])
		@gtk_attributes[row["gtkobjectid"]][row["gtkobjecttype"]]=Hash.new unless @gtk_attributes[row["gtkobjectid"]].has_key?(row["gtkobjecttype"])
		@gtk_attributes[row["gtkobjectid"]][row["gtkobjecttype"]][row["attribute"]]=row['data']
		cnt+=1
	}
	cache.set("attributes",@gtk_attributes)
	einfo("loaded #{cnt} attributes")
end