Class: Hightouch::Blog
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
Instance Method Summary collapse
- #archives ⇒ Object
- #blog_posting(path) ⇒ Object
- #blog_postings ⇒ Object
- #categories ⇒ Object
- #create_archive(type, attrs) ⇒ Object
- #find_archive(type, key) ⇒ Object
-
#initialize(app = nil) ⇒ Blog
constructor
A new instance of Blog.
- #remove_archive(archive) ⇒ Object
- #tags ⇒ Object
- #touch_blog_posting(page) ⇒ Object
Constructor Details
#initialize(app = nil) ⇒ Blog
Returns a new instance of Blog.
12 13 14 |
# File 'lib/hightouch/blog.rb', line 12 def initialize(app = nil) @app = app end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
10 11 12 |
# File 'lib/hightouch/blog.rb', line 10 def app @app end |
Instance Method Details
#archives ⇒ Object
16 17 18 |
# File 'lib/hightouch/blog.rb', line 16 def archives Hash[archive_cache.sort_by { |k, v| v.name }.reverse] end |
#blog_posting(path) ⇒ Object
56 57 58 |
# File 'lib/hightouch/blog.rb', line 56 def blog_posting(path) blog_posting_cache.values.select { |v| v.url == path }.first end |
#blog_postings ⇒ Object
28 29 30 |
# File 'lib/hightouch/blog.rb', line 28 def blog_postings Hash[blog_posting_cache.sort_by { |k, v| v.date_created }.reverse] end |
#categories ⇒ Object
20 21 22 |
# File 'lib/hightouch/blog.rb', line 20 def categories Hash[category_cache.sort_by { |k, v| v.name }] end |
#create_archive(type, attrs) ⇒ Object
32 33 34 |
# File 'lib/hightouch/blog.rb', line 32 def create_archive(type, attrs) send("#{type.name.split(/::/).last.downcase}_cache".to_sym)[attrs[:name]] = type.new(attrs) end |
#find_archive(type, key) ⇒ Object
36 37 38 |
# File 'lib/hightouch/blog.rb', line 36 def find_archive(type, key) send("#{type.name.split(/::/).last.downcase}_cache".to_sym)[key] end |
#remove_archive(archive) ⇒ Object
40 41 42 43 |
# File 'lib/hightouch/blog.rb', line 40 def remove_archive(archive) key = archive.name send("#{archive.class.name.split(/::/).last.downcase}_cache".to_sym).delete(key) end |
#tags ⇒ Object
24 25 26 |
# File 'lib/hightouch/blog.rb', line 24 def Hash[tag_cache.sort_by { |k, v| v.name }] end |
#touch_blog_posting(page) ⇒ Object
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/hightouch/blog.rb', line 45 def touch_blog_posting(page) key = page.data.title blog_posting = blog_posting_cache[key] if blog_posting blog_posting.update else blog_posting_cache[key] = BlogPosting.new(page, self) end end |