Module: ActiveRecord::RelationsAnnotations::ClassMethods
- Defined in:
- lib/active_record/relations_annotations.rb
Instance Method Summary collapse
- #annotate(**values) ⇒ Object
-
#annotated ⇒ Object
This should never be explicitly called, but if done, nothing should happen.
- #annotations ⇒ Object
Instance Method Details
#annotate(**values) ⇒ Object
12 13 14 15 16 17 18 |
# 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 ⇒ Object
This should never be explicitly called, but if done, nothing should happen
26 27 28 29 30 31 32 |
# 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 ⇒ Object
20 21 22 |
# File 'lib/active_record/relations_annotations.rb', line 20 def annotations annotated.instance_variable_get(:@_annotations) end |