Class: ActiveRecord::Relation
- Inherits:
-
Object
- Object
- ActiveRecord::Relation
show all
- Defined in:
- lib/collection_extensions.rb
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
25
26
27
28
29
30
31
|
# File 'lib/collection_extensions.rb', line 25
def method_missing(method, *args, &block)
if extension_module and extension_module.method_defined? method
to_a.send(method, *args, &block)
else
orig_method_missing(method, *args, &block)
end
end
|
Instance Method Details
#extension_module ⇒ Object
18
19
20
21
22
23
|
# File 'lib/collection_extensions.rb', line 18
def extension_module
extension_klass = CollectionExtensions::Config.naming_convention % @klass.to_s
if Object.constants.include? extension_klass.to_sym
Object.const_get(extension_klass)
end
end
|
#orig_method_missing ⇒ Object
8
|
# File 'lib/collection_extensions.rb', line 8
alias :orig_method_missing :method_missing
|
#orig_to_a ⇒ Object
7
|
# File 'lib/collection_extensions.rb', line 7
alias :orig_to_a :to_a
|
#to_a ⇒ Object
10
11
12
13
14
15
16
|
# File 'lib/collection_extensions.rb', line 10
def to_a
records = orig_to_a
records.extend extension_module if extension_module
records
end
|