Instance methods that determine based on the :if and
:unless conditions, whether a version is to be create or
updated.
After first determining whether the :if and
:unless conditions are satisfied, the original, unaliased
create_version? method is called to determine whether a new
version should be created upon update of the ActiveRecord::Base instance.
# File lib/vestal_versions/conditions.rb, line 45 def create_version_with_conditions? version_conditions_met? && create_version_without_conditions? end
After first determining whether the :if and
:unless conditions are satisfied, the original, unaliased
update_version? method is called to determine whther the last
version should be updated to include changes merged from the current
ActiveRecord::Base instance update.
The overridden update_version? method simply returns false,
effectively delegating the decision to whether the :if and
:unless conditions are met.
# File lib/vestal_versions/conditions.rb, line 56 def update_version_with_conditions? version_conditions_met? && update_version_without_conditions? end
Simply checks whether the :if and :unless
conditions given in the versioned options are met: meaning
that all procs in the :if array must evaluate to a non-false,
non-nil value and that all procs in the :unless array must all
evaluate to either false or nil.
# File lib/vestal_versions/conditions.rb, line 64 def version_conditions_met? vestal_versions_options[:if].all?{|p| p.call(self) } && !vestal_versions_options[:unless].any?{|p| p.call(self) } end