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(options) ⇒ Object
After the original
prepare_versioned_optionsmethod cleans the given options, this alias also extracts the:ifand:unlessoptions, chaning them into arrays and converting any symbols to procs.
Instance Method Details
#prepare_versioned_options(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.
16 17 18 19 20 21 22 23 |
# File 'lib/vestal_versions/conditions.rb', line 16 def () result = super() [:if] = Array(.delete(:if)).map(&:to_proc) [:unless] = Array(.delete(:unless)).map(&:to_proc) result end |