Class: DraftPunk::SetupModel
- Inherits:
-
Object
- Object
- DraftPunk::SetupModel
- Defined in:
- lib/activerecord/setup_model.rb
Instance Method Summary collapse
-
#initialize(top_level_model, associations: [], nullify: [], set_default_scope: false, allow_previous_versions_to_be_changed: true) ⇒ SetupModel
constructor
A new instance of SetupModel.
- #make_approvable! ⇒ Object
Constructor Details
#initialize(top_level_model, associations: [], nullify: [], set_default_scope: false, allow_previous_versions_to_be_changed: true) ⇒ SetupModel
Returns a new instance of SetupModel.
13 14 15 16 |
# File 'lib/activerecord/setup_model.rb', line 13 def initialize(top_level_model, associations: [], nullify: [], set_default_scope: false, allow_previous_versions_to_be_changed: true) @top_level_model, @associations, @nullify = top_level_model, associations, nullify @set_default_scope, @allow_previous_versions_to_be_changed = set_default_scope, allow_previous_versions_to_be_changed end |
Instance Method Details
#make_approvable! ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/activerecord/setup_model.rb', line 18 def make_approvable! return unless model_table_exists? # Short circuits if you're migrating @top_level_model.extend Model::ActiveRecordClassMethods @associations = @top_level_model.draft_target_associations if @associations.empty? set_valid_associations @top_level_model, @associations raise DraftPunk::ConfigurationError, "Cannot call requires_approval multiple times for #{@top_level_model.name}" if @top_level_model.const_defined?(:DRAFT_PUNK_IS_SETUP) @top_level_model.const_set :DRAFT_NULLIFY_ATTRIBUTES, Array(@nullify).flatten.freeze @top_level_model.amoeba do nullify @nullify # Note that the amoeba associations and customize options are being set in setup_associations_and_scopes_for end setup_amoeba_for @top_level_model, set_default_scope: @set_default_scope, allow_previous_versions_to_be_changed: @allow_previous_versions_to_be_changed true end |