Class: Blogit::ApplicationController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/blogit/application_controller.rb

Overview

Inherits from the application's controller instead of ActionController::Base

Direct Known Subclasses

CommentsController, PostsController

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Object) blogit_authenticate(options = {})

Sets a class method to specify a before-filter calling whatever Blogit.configuration.authentication_method is set to Accepts the usual before_filter optionss



12
13
14
# File 'app/controllers/blogit/application_controller.rb', line 12

def self.blogit_authenticate(options ={})
  before_filter blogit_conf.authentication_method, options
end

+ (Object) blogit_cacher(*args)

Turns on page caching for the given actions if Blogit.configuration.cache_pages is true



24
25
26
27
28
# File 'app/controllers/blogit/application_controller.rb', line 24

def self.blogit_cacher(*args)
  if blogit_conf.cache_pages
    caches_page *args
  end
end

+ (Object) blogit_conf

A helper method to access the Blogit::configuration at the class level



18
19
20
# File 'app/controllers/blogit/application_controller.rb', line 18

def self.blogit_conf
  Blogit::configuration
end

+ (Object) blogit_sweeper(*args)

Sets a cache sweeper to observe changes if Blogit.configuration.cache_pages is true



32
33
34
35
36
# File 'app/controllers/blogit/application_controller.rb', line 32

def self.blogit_sweeper(*args)
  if blogit_conf.cache_pages
    cache_sweeper Blogit::BlogitSweeper, only: args
  end
end

Instance Method Details

- (Object) blogit_conf

A helper method to access the Blogit::configuration at the controller instance level



40
41
42
# File 'app/controllers/blogit/application_controller.rb', line 40

def blogit_conf
  self.class.blogit_conf
end

- (Object) current_blogger

Returns the currently logged in blogger by calling whatever Blogit.current_blogger_method is set to



46
47
48
# File 'app/controllers/blogit/application_controller.rb', line 46

def current_blogger
  send blogit_conf.current_blogger_method
end

- (Boolean) this_blogger?(post)

Returns true if the current_blogger is the owner of the post

Parameters:

  • post

    An instance of Blogit::Post

Returns:

  • (Boolean)


52
53
54
# File 'app/controllers/blogit/application_controller.rb', line 52

def this_blogger?(post)
  current_blogger == post.blogger
end