Class: Elastictastic::Association Private

Inherits:
Object
  • Object
show all
Defined in:
lib/elastictastic/association.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Container for information about generic Elastictastic associations – this might be an embed association or a parent/child association.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, options = {}) ⇒ Association

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Association.


11
12
13
# File 'lib/elastictastic/association.rb', line 11

def initialize(name, options = {})
  @name, @options = name.to_s, options.symbolize_keys
end

Instance Attribute Details

#nameObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


9
10
11
# File 'lib/elastictastic/association.rb', line 9

def name
  @name
end

#optionsObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


9
10
11
# File 'lib/elastictastic/association.rb', line 9

def options
  @options
end

Instance Method Details

#class_nameObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


15
16
17
# File 'lib/elastictastic/association.rb', line 15

def class_name
  @options[:class_name] || @name.to_s.classify
end

#clazzObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


19
20
21
# File 'lib/elastictastic/association.rb', line 19

def clazz
  @clazz ||= class_name.constantize
end

#extract(instance) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


23
24
25
# File 'lib/elastictastic/association.rb', line 23

def extract(instance)
  instance.__send__(name)
end