Sha256: f65aaea759222e0ac39e949fa6e3f16f55da1b7cc55ae8f6580da5544dc00d8d

Contents?: true

Size: 1.47 KB

Versions: 2

Compression:

Stored size: 1.47 KB

Contents

require 'active_support'

class Irwi::Config

  attr_accessor_with_default :controller_name, 'wiki_pages'

  attr_accessor_with_default :user_class_name, 'User'

  attr_accessor_with_default :page_class_name, 'WikiPage'
  attr_accessor_with_default :page_version_class_name, 'WikiPageVersion'
  attr_accessor_with_default :page_attachment_class_name do
    # Can be for example 'WikiPageAttachment'
    nil
  end

  attr_accessor_with_default :page_version_foreign_key, 'page_id'

  # Object using to format content
  attr_accessor_with_default :formatter do
    require 'irwi/formatters/red_cloth'

    Irwi::Formatters::RedCloth.new
  end

  # Object using to compare pages
  attr_accessor_with_default :comparator do
    require 'irwi/comparators/diff_lcs'

    Irwi::Comparators::DiffLcs.new
  end

  # Object using to paginate collections
  attr_accessor_with_default :paginator do
    require 'irwi/paginators/none'

    Irwi::Paginators::None.new
  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-0.4.1 lib/irwi/config.rb
irwi-0.4.0 lib/irwi/config.rb