class Surus::JSON::HasManyThroughScopeBuilder
Public Instance Methods
association_primary_key()
click to toggle source
# File lib/surus/json/has_many_through_scope_builder.rb, line 64 def association_primary_key quote_column_name association.association_primary_key end
association_table()
click to toggle source
# File lib/surus/json/has_many_through_scope_builder.rb, line 60 def association_table quote_table_name association.klass.table_name end
foreign_key()
click to toggle source
# File lib/surus/json/has_many_through_scope_builder.rb, line 40 def foreign_key quote_column_name association.foreign_key end
join_through_table_foreign_key_on_association()
click to toggle source
# File lib/surus/json/has_many_through_scope_builder.rb, line 24 def join_through_table_foreign_key_on_association "JOIN #{through_table} ON #{through_table}.#{through_primary_key}=#{association_table}.#{foreign_key}" end
join_through_table_foreign_key_on_through()
click to toggle source
# File lib/surus/json/has_many_through_scope_builder.rb, line 28 def join_through_table_foreign_key_on_through "JOIN #{through_table} ON #{through_table}.#{foreign_key}=#{association_table}.#{association_primary_key}" end
outside_primary_key()
click to toggle source
# File lib/surus/json/has_many_through_scope_builder.rb, line 36 def outside_primary_key quote_column_name outside_class.primary_key end
outside_table()
click to toggle source
# File lib/surus/json/has_many_through_scope_builder.rb, line 32 def outside_table quote_table_name outside_class.table_name end
scope()
click to toggle source
# File lib/surus/json/has_many_through_scope_builder.rb, line 4 def scope s = association .klass .joins(through_table_join) .where("#{through_table}.#{through_foreign_key}=#{outside_table}.#{outside_primary_key}") s = s.instance_eval(&association.scope) if association.scope s end
through_association_foreign_key()
click to toggle source
# File lib/surus/json/has_many_through_scope_builder.rb, line 56 def through_association_foreign_key quote_column_name through_reflection.association_foreign_key end
through_foreign_key()
click to toggle source
# File lib/surus/json/has_many_through_scope_builder.rb, line 52 def through_foreign_key quote_column_name through_reflection.foreign_key end
through_primary_key()
click to toggle source
# File lib/surus/json/has_many_through_scope_builder.rb, line 48 def through_primary_key quote_column_name through_reflection.active_record_primary_key end
through_table()
click to toggle source
# File lib/surus/json/has_many_through_scope_builder.rb, line 44 def through_table quote_table_name through_reflection.table_name end
through_table_join()
click to toggle source
# File lib/surus/json/has_many_through_scope_builder.rb, line 16 def through_table_join if foreign_key == through_association_foreign_key join_through_table_foreign_key_on_association else join_through_table_foreign_key_on_through end end