| | 170 | class Module #:nodoc: |
|---|
| | 171 | # Use const_missing to autoload associations so we don't have to |
|---|
| | 172 | # require_association when using single-table inheritance. |
|---|
| | 173 | def const_missing(class_id) |
|---|
| | 174 | if Object.const_defined?(:Controllers) and Object::Controllers.const_available?(class_id) |
|---|
| | 175 | return Object::Controllers.const_get(class_id) |
|---|
| | 176 | end |
|---|
| | 177 | |
|---|
| | 178 | begin |
|---|
| | 179 | require_dependency(class_id.to_s.demodulize.underscore) |
|---|
| | 180 | if Object.const_defined?(class_id) then return Object.const_get(class_id) else raise LoadError end |
|---|
| | 181 | rescue LoadError => e |
|---|
| | 182 | raise NameError.new("uninitialized constant #{class_id}").copy_blame!(e) |
|---|
| | 183 | end |
|---|
| | 184 | end |
|---|
| | 185 | end |
|---|
| | 186 | |
|---|
| 171 | | class << self |
|---|
| 172 | | # Use const_missing to autoload associations so we don't have to |
|---|
| 173 | | # require_association when using single-table inheritance. |
|---|
| 174 | | def const_missing(class_id) |
|---|
| 175 | | if Object.const_defined?(:Controllers) and Object::Controllers.const_available?(class_id) |
|---|
| 176 | | return Object::Controllers.const_get(class_id) |
|---|
| 177 | | end |
|---|
| 178 | | |
|---|
| 179 | | begin |
|---|
| 180 | | require_dependency(class_id.to_s.demodulize.underscore) |
|---|
| 181 | | if Object.const_defined?(class_id) then return Object.const_get(class_id) else raise LoadError end |
|---|
| 182 | | rescue LoadError => e |
|---|
| 183 | | raise NameError.new("uninitialized constant #{class_id}").copy_blame!(e) |
|---|
| 184 | | end |
|---|
| 185 | | end |
|---|
| 186 | | end |
|---|
| 187 | | |
|---|