Module: Elasticsearch::Persistence::Delegation::DelegateCache

Defined in:
lib/elasticsearch/persistence/relation/delegation.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(child_class) ⇒ Object



22
23
24
25
# File 'lib/elasticsearch/persistence/relation/delegation.rb', line 22

def self.extended(child_class)
  child_class.initialize_relation_delegate_cache
  super
end

Instance Method Details

#initialize_relation_delegate_cacheObject

:nodoc:



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/elasticsearch/persistence/relation/delegation.rb', line 9

def initialize_relation_delegate_cache # :nodoc:
  @relation_delegate_cache = cache = {}
  [
    Elasticsearch::Persistence::Relation,
  ].each do |klass|
    delegate = Class.new(klass) {
      include ClassSpecificRelation
    }
    const_set klass.name.gsub("::", "_"), delegate
    cache[klass] = delegate
  end
end

#relation_delegate_class(klass) ⇒ Object

:nodoc:



5
6
7
# File 'lib/elasticsearch/persistence/relation/delegation.rb', line 5

def relation_delegate_class(klass) # :nodoc:
  @relation_delegate_cache[klass]
end