lib/active_metadata/base.rb in active_metadata-0.3.2 vs lib/active_metadata/base.rb in active_metadata-0.4.1
- old
+ new
@@ -22,11 +22,11 @@
before_update :manage_concurrency
after_save :save_history
attr_accessor :conflicts
attr_accessor :active_metadata_timestamp
- class_variable_set("@@metadata_id_from", args.empty? ? nil : args[0][:metadata_id_from])
+ class_variable_set("@@active_metadata_ancestors", args.empty? ? nil : args[0][:active_metadata_ancestors])
include ActiveMetadata::Base::InstanceMethods
include ActiveMetadata::Persistence
end
@@ -56,10 +56,14 @@
def metadata_id
metadata_root.id
end
+ def metadata_class
+ metadata_root.class.to_s
+ end
+
# Normalize the active_metadata_timestamp into a float to be comparable with the history
def am_timestamp
ts = metadata_root.active_metadata_timestamp
return nil if ts.nil?
ts = ts.to_f
@@ -72,13 +76,13 @@
nil
end
end
def metadata_root
- metadata_id_from = self.class.class_variable_get("@@metadata_id_from")
- return self if metadata_id_from.nil?
+ active_metadata_ancestors = self.class.class_variable_get("@@active_metadata_ancestors")
+ return self if active_metadata_ancestors.nil?
receiver = self
- metadata_id_from.each do |item|
+ active_metadata_ancestors.each do |item|
receiver = receiver.send item
end
receiver
end