Sha256: 0039820f0accb0124b9a197f738ef0d4f7ee14bed663e1d971aeeb4e6916f939

Contents?: true

Size: 1.2 KB

Versions: 17

Compression:

Stored size: 1.2 KB

Contents

module Cms

  # Provides a global configuration setting to set a table prefix for all CMS tables.
  #
  # For example, Cms.table_prefix = "cms_" would create tables like:
  #   cms_html_blocks cms_pages
  # rather than
  #   html_blocks pages
  #
  def self.table_prefix=(prefix)
    @table_prefix = prefix
  end


  # Returns the table name prefix for models in the Cms:: Namespace
  # Prefer calling table_name_prefix to this methods
  # @return [String] nil if no namespace has been set.
  #
  def self.table_prefix
    @table_prefix
  end

  # By setting this, ActiveRecord will automatically prefix all tables in the Cms:: module to start with the value of prefix_
  # Defaults to "" if not specified.
  def self.table_name_prefix
    self.table_prefix ? self.table_prefix : ""
  end

  module Namespacing

    def self.prefixed_table_name(unprefixed_name)
      "#{Cms.table_prefix}#{unprefixed_name}"
    end
    def self.prefix(unprefixed_name)
      self.prefixed_table_name(unprefixed_name)
    end
  end

  module Behaviors
    # Noop - This will be automatically included on all ActiveRecord classes. I don't want to move this, so
    # I'm leaving it as a harmless NOOP for now.
    module Namespacing
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
browsercms-3.5.7 lib/cms/behaviors/namespacing.rb
browsercms-3.5.6 lib/cms/behaviors/namespacing.rb
browsercms-3.5.5 lib/cms/behaviors/namespacing.rb
browsercms-3.5.4 lib/cms/behaviors/namespacing.rb
browsercms-3.5.3 lib/cms/behaviors/namespacing.rb
browsercms-3.5.2 lib/cms/behaviors/namespacing.rb
browsercms-3.5.1 lib/cms/behaviors/namespacing.rb
browsercms-3.5.0 lib/cms/behaviors/namespacing.rb
browsercms-3.5.0.rc3 lib/cms/behaviors/namespacing.rb
browsercms-3.5.0.rc2 lib/cms/behaviors/namespacing.rb
browsercms-3.5.0.rc1 lib/cms/behaviors/namespacing.rb
browsercms-3.4.2 lib/cms/behaviors/namespacing.rb
browsercms-3.4.2.rc1 lib/cms/behaviors/namespacing.rb
browsercms-3.4.1 lib/cms/behaviors/namespacing.rb
browsercms-3.4.0 lib/cms/behaviors/namespacing.rb
browsercms-3.4.0.rc2 lib/cms/behaviors/namespacing.rb
browsercms-3.4.0.rc1 lib/cms/behaviors/namespacing.rb