module ROM::SQL::Associations::SelfRef

Public Class Methods

included(klass) click to toggle source
Calls superclass method
# File lib/rom/sql/associations/self_ref.rb, line 7
def self.included(klass)
  super
  klass.memoize :join_keys, :source_table, :source_alias, :source_attr, :target_attr
end

Public Instance Methods

join_keys() click to toggle source

@api public

# File lib/rom/sql/associations/self_ref.rb, line 13
def join_keys
  { source_attr => target_attr }
end
source_attr() click to toggle source

@api public

# File lib/rom/sql/associations/self_ref.rb, line 18
def source_attr
  source[source_key].qualified(source_alias)
end
target_attr() click to toggle source

@api public

# File lib/rom/sql/associations/self_ref.rb, line 23
def target_attr
  target[target_key].qualified
end

Protected Instance Methods

source_alias() click to toggle source

@api private

# File lib/rom/sql/associations/self_ref.rb, line 35
def source_alias
  self_ref? ? :"#{source.name.dataset.to_s[0]}_0" : source.name.dataset
end
source_table() click to toggle source

@api private

# File lib/rom/sql/associations/self_ref.rb, line 30
def source_table
  self_ref? ? Sequel.as(source.name.dataset, source_alias) : source.name.dataset
end