Sha256: 600a2578c399a63144b5813cdf11d36317ab9f6b9688b15d1f286390cf86684a

Contents?: true

Size: 499 Bytes

Versions: 4

Compression:

Stored size: 499 Bytes

Contents

module DoubanHelper
  def douban
    @douban ||= (session[:douban] && session[:douban][:access_token]) ? Douban.load(session[:douban]) : nil
  end
  
  def douban_authorized?
    !douban.nil?
  end
  
  def douban_auth_required
    douban_authorized? || redirect_to(douban_auth_path)
  end
  
  def douban_auth_or_login_required
    douban_authorized? || login_required
  end
  
  def self.included(base)
    base.send :helper_method, :douban_authorized? if base.respond_to? :helper_method
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
douban-rails2.3-0.7.0 generators/douban/templates/douban_helper.rb
douban-rails2.3-0.6.5 generators/douban/templates/douban_helper.rb
douban-rails2.3-0.6.4 generators/douban/templates/douban_helper.rb
douban-0.1.0 lib/generators/douban/templates/douban_helper.rb