lib/arel/engines/sql/relations/table.rb in arel-0.3.1 vs lib/arel/engines/sql/relations/table.rb in arel-0.3.2

- old
+ new

@@ -1,14 +1,15 @@ module Arel - class Table < Relation - include Recursion::BaseCase + class Table + include Relation, Recursion::BaseCase cattr_accessor :engine, :tables attr_reader :name, :engine, :table_alias, :options def initialize(name, options = {}) @name = name.to_s + @table_exists = nil if options.is_a?(Hash) @options = options @engine = options[:engine] || Table.engine @table_alias = options[:as].to_s if options[:as].present? && options[:as].to_s != @name @@ -39,11 +40,13 @@ end def attributes return @attributes if defined?(@attributes) if table_exists? - @attributes = columns.collect { |column| Attribute.new(self, column.name.to_sym) } + @attributes = columns.collect do |column| + Sql::Attributes.for(column).new(column, self, column.name.to_sym) + end else [] end end @@ -51,13 +54,9 @@ self == other end def hash @hash ||= :name.hash - end - - def format(attribute, value) - attribute.column.type_cast(value) end def column_for(attribute) has_attribute?(attribute) and columns.detect { |c| c.name == attribute.name.to_s } end