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

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

Instance Method Summary collapse

Instance Method Details

#define_attribute_methodsObject



72
73
74
75
76
77
78
79
80
81
# File 'lib/multiple_table_inheritance/child/base.rb', line 72

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



89
90
91
92
93
# File 'lib/multiple_table_inheritance/child/base.rb', line 89

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

#inherit_parent_attributesObject



83
84
85
86
87
# File 'lib/multiple_table_inheritance/child/base.rb', line 83

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



99
100
101
# File 'lib/multiple_table_inheritance/child/base.rb', line 99

def inherited_attribute_methods_generated!
  @inherited_attribute_methods_generated = true
end

#inherited_attribute_methods_generated?Boolean

Returns:

  • (Boolean)


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

def inherited_attribute_methods_generated?
  @inherited_attribute_methods_generated ||= false
end