Class: ActiveWindow::ActiveColumn
- Inherits:
-
Object
- Object
- ActiveWindow::ActiveColumn
- Defined in:
- lib/active_window/active_column.rb
Overview
ActiveColumn is used to define columns for ActiveTreeStore
Direct Known Subclasses
ActiveCompositeColumn, ActiveDateColumn, ActiveFloatColumn, ActiveImageColumn, ActiveTextColumn, ActiveToggleColumn
Constant Summary collapse
- ClassesToSymbols =
{ TrueClass => :boolean, FalseClass => :boolean, String => :string, Time => :datetime, Date => :datetime, Fixnum => :integer, Bignum => :integer, Integer => :integer, Float => :float, Gdk::Pixbuf => :image }
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
-
.create(id, name, klass = :string, opts = {}) ⇒ Object
column: ActiveRecord::ConnectionAdapters::MysqlColumn.
Instance Method Summary collapse
-
#data_class ⇒ Object
return the class of the value held for this column in the model.
-
#data_value(ar_object) ⇒ Object
given an active record object, return the attribute value that corresponds to this column.
- #hide! ⇒ Object
-
#initialize(id, name, opts = {}) ⇒ ActiveColumn
constructor
A new instance of ActiveColumn.
- #renderer ⇒ Object
-
#view ⇒ Object
return a Gtk::TreeViewColumn appropriate for showing this column.
- #virtual? ⇒ Boolean
- #visible? ⇒ Boolean
Constructor Details
#initialize(id, name, opts = {}) ⇒ ActiveColumn
Returns a new instance of ActiveColumn.
43 44 45 46 47 48 49 |
# File 'lib/active_window/active_column.rb', line 43 def initialize(id, name, opts={}) self.id = id self.name = name @virtual = opts[:virtual] == true ? true : false @visible = opts[:visible] == false ? false : true #puts 'new column: %s %s' % [self.class, name] end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
11 12 13 |
# File 'lib/active_window/active_column.rb', line 11 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
11 12 13 |
# File 'lib/active_window/active_column.rb', line 11 def name @name end |
Class Method Details
.create(id, name, klass = :string, opts = {}) ⇒ Object
column: ActiveRecord::ConnectionAdapters::MysqlColumn
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/active_window/active_column.rb', line 29 def self.create(id, name, klass=:string, opts={}) klass = ClassesToSymbols[klass] if klass.is_a?(Class) subclass = case klass # ignore warning this creates when :string; ActiveTextColumn when :datetime; ActiveDateColumn when :integer; ActiveIntegerColumn when :float; ActiveFloatColumn when :boolean; ActiveToggleColumn when :image; ActiveImageColumn else; self end return subclass.new(id, name.to_s, opts) end |
Instance Method Details
#data_class ⇒ Object
return the class of the value held for this column in the model
73 74 75 |
# File 'lib/active_window/active_column.rb', line 73 def data_class Object end |
#data_value(ar_object) ⇒ Object
given an active record object, return the attribute value that corresponds to this column. the returned value must match the class returned in data_class. so, you might have to do some conversion.
81 82 83 |
# File 'lib/active_window/active_column.rb', line 81 def data_value(ar_object) ar_object.send(self.name) end |
#hide! ⇒ Object
55 56 57 |
# File 'lib/active_window/active_column.rb', line 55 def hide! @visible = false end |
#renderer ⇒ Object
68 69 70 |
# File 'lib/active_window/active_column.rb', line 68 def renderer raise "There is no way to render #{name} yet." end |
#view ⇒ Object
return a Gtk::TreeViewColumn appropriate for showing this column
64 65 66 |
# File 'lib/active_window/active_column.rb', line 64 def view raise "There is no way to show #{name} yet." end |
#virtual? ⇒ Boolean
51 52 53 |
# File 'lib/active_window/active_column.rb', line 51 def virtual? @virtual end |
#visible? ⇒ Boolean
59 60 61 |
# File 'lib/active_window/active_column.rb', line 59 def visible? @visible end |