Module: ActiveRecord::ActsAs::ClassMethods
- Defined in:
- lib/active_record/acts_as/class_methods.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/active_record/acts_as/class_methods.rb', line 26
def method_missing(method, *args, &block)
if acting_as_model.methods_callable_by_submodel.include?(method)
result = acting_as_model.public_send(method, *args, &block)
if result.is_a?(ActiveRecord::Relation)
all.joins(acting_as_name.to_sym).merge(result)
else
result
end
else
super
end
end
|
Class Method Details
.included(module_) ⇒ Object
10
11
12
|
# File 'lib/active_record/acts_as/class_methods.rb', line 10
def self.included(module_)
module_.prepend ReflectionsWithActsAs
end
|
Instance Method Details
#actables ⇒ Object
18
19
20
|
# File 'lib/active_record/acts_as/class_methods.rb', line 18
def actables
acting_as_model.where(actable_id: select(:id))
end
|
#respond_to_missing?(method, include_private = false) ⇒ Boolean
22
23
24
|
# File 'lib/active_record/acts_as/class_methods.rb', line 22
def respond_to_missing?(method, include_private = false)
acting_as_model.methods_callable_by_submodel.include?(method) || super
end
|
#validators_on(*args) ⇒ Object
14
15
16
|
# File 'lib/active_record/acts_as/class_methods.rb', line 14
def validators_on(*args)
super + acting_as_model.validators_on(*args)
end
|