Class: Effective::Page

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/effective/page.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#current_userObject

Returns the value of attribute current_user.



3
4
5
# File 'app/models/effective/page.rb', line 3

def current_user
  @current_user
end

This is for the form



151
152
153
# File 'app/models/effective/page.rb', line 151

def menu_root_level
  @menu_root_level
end

Instance Method Details

#bodyObject

As per has_many_rich_texts



115
116
117
# File 'app/models/effective/page.rb', line 115

def body
  rich_text_body
end

#duplicateObject

Returns a duplicated post object, or throws an exception



128
129
130
131
132
133
134
135
136
137
138
139
# File 'app/models/effective/page.rb', line 128

def duplicate
  Page.new(attributes.except('id', 'updated_at', 'created_at')).tap do |page|
    page.title = page.title + ' (Copy)'
    page.slug = page.slug + '-copy'

    rich_texts.each do |rt|
      page.send("rich_text_#{rt.name}=", rt.body)
    end

    page.draft = true
  end
end

#duplicate!Object



141
142
143
# File 'app/models/effective/page.rb', line 141

def duplicate!
  duplicate.tap { |page| page.save! }
end

Returns:

  • (Boolean)


163
164
165
# File 'app/models/effective/page.rb', line 163

def menu_child?
  menu? && menu_parent_id.present?
end

Returns:

  • (Boolean)


159
160
161
# File 'app/models/effective/page.rb', line 159

def menu_parent?
  menu? && menu_children.to_a.present?
end

Returns:

  • (Boolean)


155
156
157
# File 'app/models/effective/page.rb', line 155

def menu_root?
  menu? && menu_parent_id.blank?
end

When true, this should not appear in sitemap.xml and should return 404 if visited

Returns:

  • (Boolean)


146
147
148
# File 'app/models/effective/page.rb', line 146

def menu_root_with_children?
  menu_root? && menu_parent?
end


110
111
112
# File 'app/models/effective/page.rb', line 110

def menu_to_s
  (menu_title.presence || title)
end

#published?Boolean

Returns:

  • (Boolean)


123
124
125
# File 'app/models/effective/page.rb', line 123

def published?
  !draft?
end


119
120
121
# File 'app/models/effective/page.rb', line 119

def sidebar
  rich_text_sidebar
end

#to_sObject



106
107
108
# File 'app/models/effective/page.rb', line 106

def to_s
  title
end