Class: Drift::BlogPost

Inherits:
StaticModel show all
Defined in:
app/models/drift/blog_post.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from StaticModel

all, all_files, find_by_file

Constructor Details

#initialize(args) ⇒ BlogPost

Returns a new instance of BlogPost.



15
16
17
18
# File 'app/models/drift/blog_post.rb', line 15

def initialize(args)
  super
  set_attributes_from_file args[:file]
end

Instance Attribute Details

#authorObject

Returns the value of attribute author.



5
6
7
# File 'app/models/drift/blog_post.rb', line 5

def author
  @author
end

#contentObject

Returns the value of attribute content.



5
6
7
# File 'app/models/drift/blog_post.rb', line 5

def content
  @content
end

#dateObject

Returns the value of attribute date.



5
6
7
# File 'app/models/drift/blog_post.rb', line 5

def date
  @date
end

#slugObject

Returns the value of attribute slug.



5
6
7
# File 'app/models/drift/blog_post.rb', line 5

def slug
  @slug
end

#titleObject

Returns the value of attribute title.



5
6
7
# File 'app/models/drift/blog_post.rb', line 5

def title
  @title
end

Class Method Details

.find_by_slug(slug) ⇒ Object



7
8
9
10
11
12
13
# File 'app/models/drift/blog_post.rb', line 7

def self.find_by_slug(slug)
  file = self.all_files.detect do |f|
    slug == parse_slug_from_file(f)
  end

  find_by_file(file)
end