Sha256: f201021cd35f6c22395de46cd1fe811608a94cff4f1df332201ffabd087f21c0

Contents?: true

Size: 1.5 KB

Versions: 7

Compression:

Stored size: 1.5 KB

Contents

require "tandem/engine"
require "cancan"
require "slim-rails"
require "paperclip"
require "eco"

module Tandem
  module Configuration
    mattr_accessor :unauthorized_path, :layouts_dir, :uploaded_images_dir, :uploaded_images_template, :paperclip_options

    self.unauthorized_path = nil
    self.layouts_dir = "tandem"
    self.uploaded_images_dir = ":rails_root/public"
    self.uploaded_images_template = "/assets/images/:id/:style/:basename.:extension"
    self.paperclip_options = { :styles => { :thumb => "150x150>" },
                               :url  => Tandem::Configuration.uploaded_images_template,
                               :path => Tandem::Configuration.uploaded_images_dir + Tandem::Configuration.uploaded_images_template }

    def self.current_user_proc(&block)
      @@current_user = block
    end

    def self.user_abilities_proc(&block)
      @@user_abilities = block
    end

    def self.current_user
      raise(ConfigurationNotFound.new("Tandem::Configuration.current_user { ... }")) unless @@current_user
      @@current_user
    end

    def self.user_abilities
      raise(ConfigurationNotFound.new("Tandem::Configuration.user_abilities { |user| ... }")) unless @@user_abilities
      @@user_abilities
    end
  end

  class ConfigurationNotFound < StandardError
    attr_accessor :message
    def initialize(option)
      @message = "Tandem configuration option not found. " +
        "Please complete this in config/initializers/tandem.rb with this line:\n\n" +
        "#{option}"
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
tandem-0.2.5 lib/tandem.rb
tandem-0.2.4 lib/tandem.rb
tandem-0.2.3 lib/tandem.rb
tandem-0.2.2 lib/tandem.rb
tandem-0.2.1 lib/tandem.rb
tandem-0.2.0 lib/tandem.rb
tandem-0.2.0.rc lib/tandem.rb