Module: Elasticsearch::Persistence::Delegation
- Extended by:
- ActiveSupport::Concern
- Included in:
- Relation
- Defined in:
- lib/elasticsearch/persistence/relation/delegation.rb
Overview
:nodoc:
Defined Under Namespace
Modules: ClassMethods, ClassSpecificRelation, DelegateCache
Constant Summary collapse
- BLACKLISTED_ARRAY_METHODS =
This module creates compiled delegation methods dynamically at runtime, which makes subsequent calls to that method faster by avoiding method_missing. The delegations may vary depending on the klass of a relation, so we create a subclass of Relation for each different klass, and the delegations are compiled into that subclass only.
[ :compact!, :flatten!, :reject!, :reverse!, :rotate!, :map!, :shuffle!, :slice!, :sort!, :sort_by!, :delete_if, :keep_if, :pop, :shift, :delete_at, :compact, :select!, ].to_set
Instance Method Summary collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object (protected)
119 120 121 122 123 124 125 126 127 |
# File 'lib/elasticsearch/persistence/relation/delegation.rb', line 119 def method_missing(method, *args, &block) if @klass.respond_to?(method) scoping { @klass.public_send(method, *args, &block) } elsif array_delegable?(method) to_a.public_send(method, *args, &block) else super end end |
Instance Method Details
#respond_to?(method, include_private = false) ⇒ Boolean
108 109 110 111 |
# File 'lib/elasticsearch/persistence/relation/delegation.rb', line 108 def respond_to?(method, include_private = false) super || @klass.respond_to?(method, include_private) || array_delegable?(method) end |