### Home Classes Methods

### In Files

- lib/tinymce/rails/configuration.rb

### Parent

Object

### Namespace

- CLASS TinyMCE::Rails::Configuration::Function

### Methods

- ::assets
- ::available_languages
- ::default_language
- ::defaults
- ::new
- ::new_with_defaults
- #merge
- #options_for_tinymce

### Class/Module Index

Quicksearch

- TinyMCE
- TinyMCE::JsonManifest
- TinyMCE::NullManifest
- TinyMCE::Rails
- TinyMCE::Rails::AssetInstaller
- TinyMCE::Rails::AssetManifest
- TinyMCE::Rails::Configuration
- TinyMCE::Rails::Configuration::Function
- TinyMCE::Rails::ConfigurationFile
- TinyMCE::Rails::Engine
- TinyMCE::Rails::Helper
- TinyMCE::Rails::MultipleConfiguration
- TinyMCE::YamlManifest

No matching classes.

# TinyMCE::Rails::Configuration

### Attributes

options[R]

### Public Class Methods

assets() click to toggle source

    # File lib/tinymce/rails/configuration.rb, line 69
    def self.assets
      Rails.application.assets
    end

available_languages() click to toggle source

Searches asset paths for TinyMCE language files.

    # File lib/tinymce/rails/configuration.rb, line 59
    def self.available_languages
      assets.paths.map { |path|
        files = assets.entries(File.join(path, "tinymce/langs"))
        files.select { |file| file.to_s =~ /\.js/ }.map { |file|
          asset = assets.attributes_for(File.join(path, file))
          asset.logical_path.sub(/\.js$/, "")
        }
      }.flatten.uniq
    end

default_language() click to toggle source

Default language falls back to English if current locale is not available.

    # File lib/tinymce/rails/configuration.rb, line 54
    def self.default_language
      I18n.locale.to_s if available_languages.include?(I18n.locale.to_s)
    end

defaults() click to toggle source

    # File lib/tinymce/rails/configuration.rb, line 11
    def self.defaults
      {
        "selector" => "textarea.tinymce"
      }
    end

new(options) click to toggle source

    # File lib/tinymce/rails/configuration.rb, line 19
    def initialize(options)
      @options = options
    end

new_with_defaults(options={}) click to toggle source

    # File lib/tinymce/rails/configuration.rb, line 23
    def self.new_with_defaults(options={})
      config = new(defaults)
      config = config.merge(options) if options
      config
    end

### Public Instance Methods

merge(options) click to toggle source

    # File lib/tinymce/rails/configuration.rb, line 49
    def merge(options)
      self.class.new(self.options.merge(options))
    end

options_for_tinymce() click to toggle source

    # File lib/tinymce/rails/configuration.rb, line 29
    def options_for_tinymce
      result = {}

      options.each do |key, value|
        if value.is_a?(Array) && value.all? { |v| v.is_a?(String) }
          result[key] = value.join(",")
        elsif value.to_s.starts_with?("function(")
          result[key] = Function.new(value)
        else
          result[key] = value
        end
      end

      if self.class.default_language
        result["language"] ||= self.class.default_language
      end

      result
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.