class Elasticsearch::Model::Extensions::DependencyTracking::DependencyTracker

Public Class Methods

new(base) click to toggle source
# File lib/elasticsearch/model/extensions/dependency_tracking/dependency_tracker.rb, line 6
def initialize(base)
  @base = base
end

Public Instance Methods

base() click to toggle source
# File lib/elasticsearch/model/extensions/dependency_tracking/dependency_tracker.rb, line 10
def base
  @base
end
dependent_custom_attributes() click to toggle source

@return [Hash<Array<String>, Array<String>>]

# File lib/elasticsearch/model/extensions/dependency_tracking/dependency_tracker.rb, line 15
def dependent_custom_attributes
  @dependent_custom_attributes
end
dependent_custom_attributes=(new_value) click to toggle source

@param [Hash<Array<String>, Array<String>>] new_value

# File lib/elasticsearch/model/extensions/dependency_tracking/dependency_tracker.rb, line 20
def dependent_custom_attributes=(new_value)
  @dependent_custom_attributes = new_value
end
each_dependent_attribute_for(changed_attributes) { |dependent_attribute| ... } click to toggle source

@param [Array<String>] changed_attributes

# File lib/elasticsearch/model/extensions/dependency_tracking/dependency_tracker.rb, line 25
def each_dependent_attribute_for(changed_attributes)
  dependent_custom_attributes.each do |attributes, dependent_attributes|
    dependent_attributes.each do |dependent_attribute|
      attributes.each do |a|
        yield dependent_attribute if changed_attributes.include? a
      end
    end
  end
end
has_association_named?(table_name) click to toggle source

@param [Symbol] table_name

# File lib/elasticsearch/model/extensions/dependency_tracking/dependency_tracker.rb, line 43
def has_association_named?(table_name)
  # TODO call `reflect_on_all_associations` through a proxy object
  base.reflect_on_all_associations.any? { |a| a.name == table_name }
end
has_dependent_fields?(field) click to toggle source

@param [String|Symbol] field

# File lib/elasticsearch/model/extensions/dependency_tracking/dependency_tracker.rb, line 36
def has_dependent_fields?(field)
  dependent_custom_attributes.any? do |from, to|
    from.include? field.to_s
  end
end