lib/sequel/plugins/bitemporal.rb in sequel_bitemporal-0.7.6 vs lib/sequel/plugins/bitemporal.rb in sequel_bitemporal-0.7.8

- old
+ new

@@ -58,10 +58,12 @@ @current_version_alias = "#{base_alias}_current_version".to_sym @audit_class = opts[:audit_class] @audit_updated_by_method = opts.fetch(:audit_updated_by_method){ :updated_by } @propagate_per_column = opts.fetch(:propagate_per_column, false) @version_uses_string_nilifier = version.plugins.map(&:to_s).include? "Sequel::Plugins::StringNilifier" + @excluded_columns = Sequel::Plugins::Bitemporal.bitemporal_excluded_columns + @excluded_columns += Array opts[:excluded_columns] if opts[:excluded_columns] @use_ranges = if opts[:ranges] db = self.db unless db.database_type==:postgres && db.server_version >= 90200 raise "Ranges require PostgreSQL 9.2" end @@ -170,11 +172,11 @@ } master.destroy_version self, expand_previous_version end end unless opts[:delegate]==false - (version.columns-bitemporal_version_columns-[:id]).each do |column| + (version.columns-master.excluded_columns).each do |column| master.class_eval <<-EOS def #{column} pending_or_current_version.#{column} if pending_or_current_version end EOS @@ -182,11 +184,11 @@ end end module ClassMethods attr_reader :version_class, :versions_alias, :current_version_alias, :propagate_per_column, :audit_class, :audit_updated_by_method, - :version_uses_string_nilifier, :use_ranges + :version_uses_string_nilifier, :use_ranges, :excluded_columns def validity_range_type @validity_range_type ||= begin valid_from_infos = db.schema( version_class.table_name @@ -250,11 +252,10 @@ def validity_range_contains(now, qualifier=nil) validity_range(qualifier).contains( Sequel.cast(now, validity_cast_type) ) end - end module DatasetMethods end module InstanceMethods attr_reader :pending_version @@ -577,10 +578,10 @@ end end end def excluded_columns - Sequel::Plugins::Bitemporal.bitemporal_excluded_columns + self.class.excluded_columns end def initial_version @initial_version ||= model.version_class.new end