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
#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.
40
41
42
|
# File 'app/models/pageflow/entry.rb', line 40
def skip_draft_creation
@skip_draft_creation
end
|
Class Method Details
.ransackable_scopes(_) ⇒ Object
107
108
109
|
# File 'app/models/pageflow/entry.rb', line 107
def self.ransackable_scopes(_)
[:with_publication_state, :published]
end
|
Instance Method Details
#duplicate ⇒ Object
95
96
97
|
# File 'app/models/pageflow/entry.rb', line 95
def duplicate
EntryDuplicate.of(self).create!
end
|
#edit_lock ⇒ Object
48
49
50
|
# File 'app/models/pageflow/entry.rb', line 48
def edit_lock
super || EditLock::Null.new(self)
end
|
#inherited_feature_state(name) ⇒ Object
52
53
54
|
# File 'app/models/pageflow/entry.rb', line 52
def inherited_feature_state(name)
account.feature_state(name)
end
|
#publish(options = {}) ⇒ Object
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'app/models/pageflow/entry.rb', line 56
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
82
83
84
85
86
87
88
89
90
91
92
93
|
# File 'app/models/pageflow/entry.rb', line 82
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.published_at = nil
revision.published_until = nil
revision.password_protected = nil
end
end
|
#should_generate_new_friendly_id? ⇒ Boolean
99
100
101
|
# File 'app/models/pageflow/entry.rb', line 99
def should_generate_new_friendly_id?
slug.blank? || title_changed?
end
|
#slug_candidates ⇒ Object
103
104
105
|
# File 'app/models/pageflow/entry.rb', line 103
def slug_candidates
[:title, [:title, :id]]
end
|
#snapshot(options) ⇒ Object
74
75
76
77
78
79
80
|
# File 'app/models/pageflow/entry.rb', line 74
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
|