Module: MultipleTableInheritance::Child::Base::AttributeMethods

Defined in:
lib/multiple_table_inheritance/child/base.rb

Instance Method Summary collapse

Instance Method Details

#define_attribute_methodsObject



69
70
71
72
73
74
75
76
77
78
# File 'lib/multiple_table_inheritance/child/base.rb', line 69

def define_attribute_methods
  super
  
  @inherited_attribute_methods_mutex.synchronize do
    return if inherited_attribute_methods_generated?
    inherit_parent_attributes
    inherit_parent_accessible_attributes
    inherited_attribute_methods_generated!
  end
end

#inherit_parent_accessible_attributesObject



86
87
88
89
90
# File 'lib/multiple_table_inheritance/child/base.rb', line 86

def inherit_parent_accessible_attributes
  parent_association_class.accessible_attributes.each do |attr|
    attr_accessible attr.to_sym
  end
end

#inherit_parent_attributesObject



80
81
82
83
84
# File 'lib/multiple_table_inheritance/child/base.rb', line 80

def inherit_parent_attributes
  inherited_columns_and_associations.each do |name|
    delegate name, "#{name}=", :to => parent_association_name
  end
end

#inherited_attribute_methods_generated!Object



96
97
98
# File 'lib/multiple_table_inheritance/child/base.rb', line 96

def inherited_attribute_methods_generated!
  @inherited_attribute_methods_generated = true
end

#inherited_attribute_methods_generated?Boolean

Returns:

  • (Boolean)


92
93
94
# File 'lib/multiple_table_inheritance/child/base.rb', line 92

def inherited_attribute_methods_generated?
  @inherited_attribute_methods_generated ||= false
end