Module: VestalVersions::Conditions::ClassMethods
- Defined in:
- lib/vestal_versions/conditions.rb
Overview
Class methods on ActiveRecord::Base to prepare the :if
and :unless
options.
Instance Method Summary collapse
-
#prepare_versioned_options_with_conditions(options) ⇒ Object
After the original
prepare_versioned_options
method cleans the given options, this alias also extracts the:if
and:unless
options, chaning them into arrays and converting any symbols to procs.
Instance Method Details
#prepare_versioned_options_with_conditions(options) ⇒ Object
After the original prepare_versioned_options
method cleans the given options, this alias also extracts the :if
and :unless
options, chaning them into arrays and converting any symbols to procs. Procs are called with the ActiveRecord model instance as the sole argument.
If all of the :if
conditions are met and none of the :unless
conditions are unmet, than version creation will proceed, assuming all other conditions are also met.
28 29 30 31 32 33 34 35 |
# File 'lib/vestal_versions/conditions.rb', line 28 def () result = () self.[:if] = Array(.delete(:if)).map(&:to_proc) self.[:unless] = Array(.delete(:unless)).map(&:to_proc) result end |