Class: ActiveRecord::Base

Inherits:
Object
  • Object
show all
Extended by:
Base::ClassMethods
Defined in:
lib/activerecord/base/instance_methods.rb

Instance Attribute Summary

Attributes included from Base::ClassMethods

#tableless_models

Instance Method Summary collapse

Methods included from Base::ClassMethods

has_tableless

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object

delegates method calls for unknown methods to the tableless model



6
7
8
9
10
11
12
13
14
15
# File 'lib/activerecord/base/instance_methods.rb', line 6

def method_missing method, *args, &block
  if self.class.tableless_models
    self.class.tableless_models.each do |column_name| 
      serialized_attribute = send(column_name)
      return serialized_attribute.send(method, *args, &block) if serialized_attribute.respond_to?(method) 
    end
  end
  
  super method, *args, &block
end