lib/active_groonga/base.rb in activegroonga-0.0.6 vs lib/active_groonga/base.rb in activegroonga-0.0.7
- old
+ new
@@ -373,11 +373,11 @@
"id"
end
# Returns an array of column objects for the table associated with this class.
def columns
- @columns ||= table.columns.collect do |column|
+ @columns ||= [IdColumn.new(table)] + table.columns.collect do |column|
Column.new(column)
end
end
# Returns a hash of column objects for the table associated with this class.
@@ -426,11 +426,17 @@
if self == Base
super
elsif abstract_class?
"#{super}(abstract)"
elsif table_exists?
- attr_list = columns.map { |c| "#{c.name}: #{c.type}" } * ', '
+ attr_list = columns.collect do |column|
+ if column.id?
+ nil
+ else
+ "#{column.name}: #{column.type}"
+ end
+ end.compact.join(', ')
"#{super}(#{attr_list})"
else
"#{super}(Table doesn't exist)"
end
end
@@ -1569,11 +1575,11 @@
# an SQL statement.
def attributes_with_quotes(include_readonly_attributes=true, attribute_names=@attributes.keys)
quoted = {}
attribute_names.each do |name|
column = column_for_attribute(name)
- next if column.nil?
+ next if column.nil? or column.id?
value = read_attribute(name)
# We need explicit to_yaml because quote() does not properly convert Time/Date fields to YAML.
if value && self.class.serialized_attributes.has_key?(name) && (value.acts_like?(:date) || value.acts_like?(:time))
value = value.to_yaml
@@ -1600,10 +1606,10 @@
end
include Validations
include AttributeMethods
include Dirty
- include Timestamp
+ include Callbacks, Observing, Timestamp
include Associations
include Aggregations, Reflection
end
end