Class: Content
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Content
- Includes:
- Mumuki::Domain::Syncable, WithDescription, WithLocale, WithMedal, WithName, WithProgress, WithSlug, WithUsages
- Defined in:
- app/models/content.rb
Instance Method Summary collapse
- #fork_to!(organization, syncer, quiet: false) ⇒ Object
- #public? ⇒ Boolean
- #to_expanded_resource_h ⇒ Object
- #to_resource_h(*args) ⇒ Object
Methods included from WithUsages
#content_used_in?, #navigable_content_in, #usage_in_organization, #usage_in_organization_of_type, #used_in?
Methods included from WithSlug
#normalize_slug!, #rebase!, #rebased_dup, #transparent_id, #transparent_params
Methods included from WithProgress
#completed_for?, #completion_percentage_for, #dirty_progress_if_structural_children_changed!, #dirty_progresses!, #has_progress_for?, #once_completed_for?, #progress_for
Methods included from Mumuki::Domain::Syncable
#platform_class_name, #sync_key
Methods inherited from ApplicationRecord
active_between, aggregate_of, all_except, defaults, #delete, #destroy!, enum_prefixed_translations_for, numbered, organic_on, resource_fields, #save, #save_and_notify!, #save_and_notify_changes!, serialize_symbolized_hash_array, teaser_on, #update_and_notify!, update_or_create!, whitelist_attributes, with_pg_retry, with_temporary_token
Methods included from WithPgLock
Instance Method Details
#fork_to!(organization, syncer, quiet: false) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/models/content.rb', line 21 def fork_to!(organization, syncer, quiet: false) rebased_dup(organization).tap do |dup| self.class.find_by(slug: dup.slug).try { |it| return it } if quiet dup.validate! fork_children_into! dup, organization, syncer dup.save validate: false syncer.export! dup end end |
#public? ⇒ Boolean
33 34 35 |
# File 'app/models/content.rb', line 33 def public? !private? end |
#to_expanded_resource_h ⇒ Object
17 18 19 |
# File 'app/models/content.rb', line 17 def (*) as_json(only: [:name, :slug, :description, :locale]).symbolize_keys end |
#to_resource_h(*args) ⇒ Object
13 14 15 |
# File 'app/models/content.rb', line 13 def to_resource_h(*args) (*args).compact end |