Class: Pageflow::Entry
Defined Under Namespace
Classes: PasswordMissingError
Constant Summary
FeatureTarget::STATE_MAPPING
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
#serializable_hash
#publication_state, #published?, #published_at, #published_until, #published_with_password_protection?
#enabled_feature_names, #feature_state, #feature_states=, #features_configuration, #own_feature_state
Instance Attribute Details
#skip_draft_creation ⇒ Object
Returns the value of attribute skip_draft_creation.
50
51
52
|
# File 'app/models/pageflow/entry.rb', line 50
def skip_draft_creation
@skip_draft_creation
end
|
Class Method Details
.ransackable_scopes(_) ⇒ Object
129
130
131
|
# File 'app/models/pageflow/entry.rb', line 129
def self.ransackable_scopes(_)
[:with_publication_state, :published]
end
|
Instance Method Details
#blacklist_for_serialization ⇒ Object
133
134
135
|
# File 'app/models/pageflow/entry.rb', line 133
def blacklist_for_serialization
[:password_digest, :features_configuration]
end
|
#duplicate ⇒ Object
117
118
119
|
# File 'app/models/pageflow/entry.rb', line 117
def duplicate
EntryDuplicate.of(self).create!
end
|
#edit_lock ⇒ Object
69
70
71
|
# File 'app/models/pageflow/entry.rb', line 69
def edit_lock
super || EditLock::Null.new(self)
end
|
#entry_template ⇒ Object
58
59
60
61
62
63
|
# File 'app/models/pageflow/entry.rb', line 58
def entry_template
@entry_template ||= EntryTemplate.find_or_initialize_by(
account_id: account.id,
entry_type_name: type_name
)
end
|
#inherited_feature_state(name) ⇒ Object
73
74
75
|
# File 'app/models/pageflow/entry.rb', line 73
def inherited_feature_state(name)
account.feature_state(name)
end
|
#publish(options = {}) ⇒ Object
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
# File 'app/models/pageflow/entry.rb', line 77
def publish(options = {})
ActiveRecord::Base.transaction do
self.first_published_at ||= Time.now
update_password!(options.slice(:password, :password_protected))
revisions.depublish_all
association(:published_revision).reset
draft.copy do |revision|
revision.creator = options[:creator]
revision.frozen_at = Time.now
revision.published_at = Time.now
revision.published_until = options[:published_until]
revision.password_protected = options[:password_protected]
end
end
end
|
#restore(options) ⇒ Object
103
104
105
106
107
108
109
110
111
112
113
114
115
|
# File 'app/models/pageflow/entry.rb', line 103
def restore(options)
restored_revision = options.fetch(:revision)
draft.update!(:frozen_at => Time.now, :creator => options[:creator], :snapshot_type => 'before_restore')
restored_revision.copy do |revision|
revision.restored_from = restored_revision
revision.frozen_at = nil
revision.snapshot_type = nil
revision.published_at = nil
revision.published_until = nil
revision.password_protected = nil
end
end
|
#should_generate_new_friendly_id? ⇒ Boolean
121
122
123
|
# File 'app/models/pageflow/entry.rb', line 121
def should_generate_new_friendly_id?
slug.blank? || title_changed?
end
|
#slug_candidates ⇒ Object
125
126
127
|
# File 'app/models/pageflow/entry.rb', line 125
def slug_candidates
[:title, [:title, :id]]
end
|
#snapshot(options) ⇒ Object
95
96
97
98
99
100
101
|
# File 'app/models/pageflow/entry.rb', line 95
def snapshot(options)
draft.copy do |revision|
revision.creator = options[:creator]
revision.frozen_at = Time.now
revision.snapshot_type = options.fetch(:type, 'auto')
end
end
|