Class: Drupal::CCK::Table
- Inherits:
-
Object
- Object
- Drupal::CCK::Table
- Defined in:
- lib/drupal/cck/builder.rb
Instance Attribute Summary collapse
-
#content_type ⇒ Object
Returns the value of attribute content_type.
Instance Method Summary collapse
- #columns ⇒ Object
- #fields ⇒ Object
- #ignore_columns ⇒ Object
-
#initialize(content_type) ⇒ Table
constructor
A new instance of Table.
- #table ⇒ Object
- #to_s ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(content_type) ⇒ Table
Returns a new instance of Table.
34 35 36 |
# File 'lib/drupal/cck/builder.rb', line 34 def initialize content_type self.content_type = content_type end |
Instance Attribute Details
#content_type ⇒ Object
Returns the value of attribute content_type.
32 33 34 |
# File 'lib/drupal/cck/builder.rb', line 32 def content_type @content_type end |
Instance Method Details
#columns ⇒ Object
46 47 48 |
# File 'lib/drupal/cck/builder.rb', line 46 def columns @columns ||= fields end |
#fields ⇒ Object
42 43 44 |
# File 'lib/drupal/cck/builder.rb', line 42 def fields Drupal::CCK::ContentNodeFieldInstance.all :content_type => content_type end |
#ignore_columns ⇒ Object
50 51 52 |
# File 'lib/drupal/cck/builder.rb', line 50 def ignore_columns %w{nid vid} end |
#table ⇒ Object
38 39 40 |
# File 'lib/drupal/cck/builder.rb', line 38 def table "content_type_#{content_type}" end |
#to_s ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/drupal/cck/builder.rb', line 54 def to_s " class #{content_type.camel_case} #{Drupal.common} storage_names[:drupal] = '#{table}' property :nid, Integer property :vid, Integer, :key => true belongs_to :node, :child_key => [:nid] #{columns.map{|c| c.to_s}.join "\n"} def self.content_type; :#{content_type}; end def content_type; :#{content_type}; end extend CCK::FieldMethods include CCK::Builder::InstanceMethods end " end |
#valid? ⇒ Boolean
73 74 75 76 77 78 |
# File 'lib/drupal/cck/builder.rb', line 73 def valid? columns true rescue MysqlError false end |