Class: Dust::Post

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Menu::ItemDependency
Defined in:
app/models/dust/post.rb

Instance Method Summary collapse

Methods included from Menu::ItemDependency

#active, #active=, #match_path, #menu, #menu=, #nav_link, #nav_link=

Instance Method Details

#filenameObject



30
31
32
# File 'app/models/dust/post.rb', line 30

def filename
  url_title
end

#filename=(filename = "") ⇒ Object



34
35
36
# File 'app/models/dust/post.rb', line 34

def filename=(filename="")
  self.menu_item.url = "/post/#{slug}"
end

#published_dateObject



14
15
16
# File 'app/models/dust/post.rb', line 14

def published_date
  self.published_at ? self.published_at.strftime("%Y/%m/%d") : Time.now.strftime("%Y/%m/%d")
end

#published_date=(date_str) ⇒ Object



18
19
20
# File 'app/models/dust/post.rb', line 18

def published_date=(date_str)
  self.published_at = Time.parse date_str
end

#share_typesObject



10
11
12
# File 'app/models/dust/post.rb', line 10

def share_types
  ['Facebook', 'Twitter']
end

#slugObject



22
23
24
# File 'app/models/dust/post.rb', line 22

def slug
  "#{published_date}/#{url_title.parameterize}"
end

#url_titleObject



26
27
28
# File 'app/models/dust/post.rb', line 26

def url_title
  title.blank? ? "empty-title" : title
end