class AdLint::Cc1::ValueVersionController
Public Class Methods
new(orig_val)
click to toggle source
# File lib/adlint/cc1/value.rb, line 2631 def initialize(orig_val) @versioning_group_stack = [RootVersioningGroup.new(orig_val)] end
Public Instance Methods
begin_forking()
click to toggle source
# File lib/adlint/cc1/value.rb, line 2652 def begin_forking current_versioning_group.begin_new_version end
copy_current_version()
click to toggle source
# File lib/adlint/cc1/value.rb, line 2698 def copy_current_version # NOTE: This method must be called between ending of the forking section # and ending of the versioning group. if current_versioning_group.sticky? current_values.each { |mval| mval.fork } end end
current_values()
click to toggle source
# File lib/adlint/cc1/value.rb, line 2639 def current_values current_versioning_group.current_values end
end_forking()
click to toggle source
# File lib/adlint/cc1/value.rb, line 2656 def end_forking current_versioning_group.end_current_version end
enter_new_versioning_group()
click to toggle source
# File lib/adlint/cc1/value.rb, line 2643 def enter_new_versioning_group new_group = VersioningGroup.new(current_versioning_group.current_version) @versioning_group_stack.push(new_group) end
fork_current_version()
click to toggle source
# File lib/adlint/cc1/value.rb, line 2660 def fork_current_version fork_all_versions end
leave_current_versioning_group()
click to toggle source
# File lib/adlint/cc1/value.rb, line 2648 def leave_current_versioning_group @versioning_group_stack.pop end
mark_current_versioning_group_as_sticky()
click to toggle source
# File lib/adlint/cc1/value.rb, line 2688 def mark_current_versioning_group_as_sticky @versioning_group_stack.reverse_each do |group| if group.sticky? break else group.sticky = true end end end
merge_forked_versions()
click to toggle source
# File lib/adlint/cc1/value.rb, line 2706 def merge_forked_versions # NOTE: This method must be called between ending of the forking section # and ending of the versioning group. base_ver = current_versioning_group.base_version case when current_versioning_group.sticky? fork_all_versions base_vals = base_ver.values.map { |mval| mval.descendants }.flatten base_ver.values = base_vals.each_with_object({}) { |mval, hash| if eql_mval = hash[mval] eql_mval._base.tag.by = mval._base.tag.by + eql_mval._base.tag.by eql_mval._base.tag.at = mval._base.tag.at + eql_mval._base.tag.at else hash[mval] = mval end }.keys when current_versioning_group.versions_forked? # NOTE: When versions in the current versioning group have been forked, # base_version of the current versioning group has already been # forked. So, it is safe to overwrite the base_version's values # with the current versioning group's initial snapshot values. init_vals = current_versioning_group.initial_values vals = base_ver.values.zip(init_vals) vals.each do |base_mval, init_sval| base_mval.delete_descendants! if base_mval.kind_of?(VersionedValue) base_mval._orig_overwrite!(init_sval, TransitionTag.new) else base_mval.overwrite!(init_sval, TransitionTag.new) end end else # NOTE: Nothing to be done when base_version of the current versioning # group has not been forked. end end
original_value()
click to toggle source
# File lib/adlint/cc1/value.rb, line 2635 def original_value root_versioning_group.initial_values.first end
thin_current_version(with_rollback)
click to toggle source
# File lib/adlint/cc1/value.rb, line 2664 def thin_current_version(with_rollback) # NOTE: This method must be called in the forking section. forked = current_version.forked? if with_rollback initial_vals = current_version.initial_values current_versioning_group.delete_current_version_completely base_vals = current_versioning_group.base_values base_vals.zip(initial_vals).each do |mval, init_val| mval.rollback! if forked mval.overwrite!(init_val, TransitionTag.new) if init_val end begin_forking else current_versioning_group.delete_current_version if forked current_versioning_group.base_values.each { |mval| mval.rollback! } end end mark_current_versioning_group_as_sticky end
Private Instance Methods
active_versioning_groups()
click to toggle source
# File lib/adlint/cc1/value.rb, line 2758 def active_versioning_groups @versioning_group_stack.drop(1) end
current_version()
click to toggle source
# File lib/adlint/cc1/value.rb, line 2766 def current_version current_versioning_group.current_version end
current_versioning_group()
click to toggle source
# File lib/adlint/cc1/value.rb, line 2762 def current_versioning_group @versioning_group_stack.last end
fork_all_versions()
click to toggle source
# File lib/adlint/cc1/value.rb, line 2745 def fork_all_versions parent_group = root_versioning_group active_versioning_groups.each do |active_group| active_group.base_version = parent_group.current_version active_group.fork_all_versions parent_group = active_group end end
root_versioning_group()
click to toggle source
# File lib/adlint/cc1/value.rb, line 2754 def root_versioning_group @versioning_group_stack.first end