module ActiveRecord::RelationsAnnotations::ClassMethods

Public Instance Methods

annotate(**values) click to toggle source
# File lib/active_record/relations_annotations.rb, line 12
def annotate(**values)
  annotated.tap do |relation|
    values.each do |key, value|
      relation.instance_variable_get(:@_annotations)[key.to_sym] = value
    end
  end
end
annotated() click to toggle source

This should never be explicitly called, but if done, nothing should happen

# File lib/active_record/relations_annotations.rb, line 26
def annotated
  all.tap do |relation|
    if relation.instance_variable_get(:@_annotations).nil?
      relation.instance_variable_set(:@_annotations, OpenStruct.new)
    end
  end
end
annotations() click to toggle source
# File lib/active_record/relations_annotations.rb, line 20
def annotations
  annotated.instance_variable_get(:@_annotations)
end