Class: Drupal::CCK::ThroughField
- Inherits:
-
Object
- Object
- Drupal::CCK::ThroughField
- Defined in:
- lib/drupal/cck/fields.rb
Instance Attribute Summary collapse
-
#field_name ⇒ Object
Returns the value of attribute field_name.
-
#table ⇒ Object
Returns the value of attribute table.
Instance Method Summary collapse
- #field ⇒ Object
- #field_type ⇒ Object
-
#initialize(field) ⇒ ThroughField
constructor
A new instance of ThroughField.
- #to_s ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(field) ⇒ ThroughField
Returns a new instance of ThroughField.
12 13 14 15 |
# File 'lib/drupal/cck/fields.rb', line 12 def initialize field self.table = field self.field_name = field.match(/^content_field_(.*)/)[1] end |
Instance Attribute Details
#field_name ⇒ Object
Returns the value of attribute field_name.
10 11 12 |
# File 'lib/drupal/cck/fields.rb', line 10 def field_name @field_name end |
#table ⇒ Object
Returns the value of attribute table.
10 11 12 |
# File 'lib/drupal/cck/fields.rb', line 10 def table @table end |
Instance Method Details
#field ⇒ Object
17 18 19 |
# File 'lib/drupal/cck/fields.rb', line 17 def field @field ||= ContentNodeField.first :field_name => "field_#{field_name}" end |
#field_type ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/drupal/cck/fields.rb', line 25 def field_type case field.type when 'userreference' "belongs_to :user, :class_name => 'Drupal::User', :child_key => [:#{field.field_name}_uid]" end end |
#to_s ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/drupal/cck/fields.rb', line 34 def to_s return "" unless valid? " class #{field_name.camel_case} #{Drupal.common} storage_names[:drupal] = '#{table}' property :vid, Integer, :key => true belongs_to :node, :class_name => 'Drupal::Node', :child_key => [:nid] Drupal::User #{field_type} end " end |
#valid? ⇒ Boolean
21 22 23 |
# File 'lib/drupal/cck/fields.rb', line 21 def valid? !field.nil? end |