Sha256: ec6ac59ba9d9393a79fcdccb34758fc4d07041a6842144dc69ceedc453023993

Contents?: true

Size: 1.9 KB

Versions: 2

Compression:

Stored size: 1.9 KB

Contents

require 'active_support'

class IrwiMod::Config

  attr_accessor :controller_name
  attr_accessor :user_class_name
  attr_accessor :page_class_name
  attr_accessor :page_version_class_name
  attr_accessor :page_attachment_class_name
  attr_accessor :page_version_foreign_key

  # Object using to format content
  attr_writer :formatter

  def formatter
    @formatter ||= begin
                     require 'irwi_mod/formatters/red_cloth'
                     
                     self.formatter = IrwiMod::Formatters::RedCloth.new
                   end	
  end

  # Object using to compare pages
  attr_writer :comparator
  
  def comparator
    @comparator ||= begin
                      require 'irwi_mod/comparators/diff_lcs'
                      
                      self.comparator = IrwiMod::Comparators::DiffLcs.new
                    end	
  end

  # Object using to paginate collections
  attr_writer :paginator
    
  def paginator
    @paginator ||= begin
                     require 'irwi_mod/paginators/none'
                     
                     self.paginator = IrwiMod::Paginators::None.new
                   end	
  end

  def initialize
    @controller_name = 'wiki_pages'
    @user_class_name = 'User'
    @page_class_name = 'WikiPage'
    @page_version_class_name = 'WikiPageVersion'
    @page_attachment_class_name = nil
    @page_version_foreign_key = 'page_id'
  end   

  def page_class
    page_class_name.constantize
  end

  def page_version_class
    page_version_class_name.constantize
  end

  def page_attachment_class
    page_attachment_class_name.constantize
  end

  def user_class
    user_class_name.constantize
  end

  def system_pages
    @system_pages ||= {
      'all' => 'all'
    }
  end

  # Add system page
  # @param action [String,Symbol] controller action
  # @param path [String] path in routes
  def add_system_page( action, path )
    system_pages[ action.to_s ] = path.to_s
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
irwi_mod-0.0.2 lib/irwi_mod/config.rb
irwi_mod-0.0.1 lib/irwi_mod/config.rb