class Dart::Reflection::SequelTable::Resolver

Attributes

relation[R]

Public Class Methods

new(table_name) click to toggle source
# File lib/dart/reflection/sequel_table/resolver.rb, line 9
def initialize(table_name)
  @table_name = table_name
  @relation   = TheSchema.instance.relation_for(table_name)
end

Public Instance Methods

association_for(ass_name) click to toggle source

Returns the association with the given ass_name or nil if one does not exist @param [String] ass_name @return [Association]

# File lib/dart/reflection/sequel_table/resolver.rb, line 22
def association_for(ass_name)
  ass = relation.all_associations.detect { |ass| ass.name == ass_name }
  ass.scope = {} # no scope can be determined by SQL reflection
  ass
end
build_from_association(association) click to toggle source
# File lib/dart/reflection/sequel_table/resolver.rb, line 14
def build_from_association(association)
  self.class.new(association.associated_table)
end
column_for(col_name) click to toggle source

Returns the column with the given col_name or nil if one does not exist @param [String] col_name @return [String]

# File lib/dart/reflection/sequel_table/resolver.rb, line 31
def column_for(col_name)
  relation.column_names.detect { |col| col == col_name }
end
table_name() click to toggle source
# File lib/dart/reflection/sequel_table/resolver.rb, line 35
def table_name
  @table_name
end