class ActiveSet::ActiveRecordSetInstruction
Public Class Methods
new(attribute_instruction, set)
click to toggle source
Calls superclass method
# File lib/active_set/active_record_set_instruction.rb, line 5 def initialize(attribute_instruction, set) @attribute_instruction = attribute_instruction @set = set super(@attribute_instruction) end
Public Instance Methods
arel_column()
click to toggle source
# File lib/active_set/active_record_set_instruction.rb, line 21 def arel_column return @arel_column if defined? @arel_column arel_column = arel_table[@attribute_instruction.attribute] arel_column = arel_column.lower if case_insensitive_operation? @arel_column = arel_column end
arel_column_name()
click to toggle source
# File lib/active_set/active_record_set_instruction.rb, line 30 def arel_column_name arel_table[@attribute_instruction.attribute].name end
arel_table()
click to toggle source
# File lib/active_set/active_record_set_instruction.rb, line 45 def arel_table # This is to work around an bug in ActiveRecord, # where BINARY fields aren't found properly when using # the `arel_table` class method to build an ARel::Node if arel_type == :binary Arel::Table.new(attribute_model.table_name) else attribute_model.arel_table end end
attribute_model()
click to toggle source
# File lib/active_set/active_record_set_instruction.rb, line 34 def attribute_model return @set.klass if @attribute_instruction.associations_array.empty? return @attribute_model if defined? @attribute_model @attribute_model = @attribute_instruction .associations_array .reduce(@set) do |obj, assoc| obj.reflections[assoc.to_s]&.klass end end
initial_relation()
click to toggle source
# File lib/active_set/active_record_set_instruction.rb, line 11 def initial_relation return @initial_relation if defined? @initial_relation @initial_relation = if @attribute_instruction.associations_array.empty? @set else @set.eager_load(@attribute_instruction.associations_hash) end end
Private Instance Methods
arel_type()
click to toggle source
# File lib/active_set/active_record_set_instruction.rb, line 58 def arel_type attribute_model &.columns_hash[@attribute_instruction.attribute] &.type end
case_insensitive_operation?()
click to toggle source
# File lib/active_set/active_record_set_instruction.rb, line 64 def case_insensitive_operation? @attribute_instruction.case_insensitive? && arel_type.presence_in(%i[string text]) end