Module: TinyMCE::OptionValidator
- Included in:
- Base
- Defined in:
- lib/tiny_mce/option_validator.rb
Overview
We use this to validate whether options passed in by the users are valid tiny mce configuration settings. Also loads which options are valid, and provides an plugins attribute to allow more configuration options dynamicly
Class Method Summary collapse
-
.load ⇒ Object
Parse the options file and load it into an array (this method is called when tiny_mce is initialized - see init.rb).
-
.options ⇒ Object
If we need to get the array of valid options, we can call this method.
-
.valid?(option) ⇒ Boolean
Does the check to see if the option is valid.
Class Method Details
.load ⇒ Object
Parse the options file and load it into an array (this method is called when tiny_mce is initialized - see init.rb)
14 15 16 17 |
# File 'lib/tiny_mce/option_validator.rb', line 14 def load @@valid_options = File.open(File.dirname(__FILE__) + '/valid_tinymce_options.yml') { |f| YAML.load(f.read) } self.plugins = Array.new end |
.options ⇒ Object
If we need to get the array of valid options, we can call this method
30 31 32 |
# File 'lib/tiny_mce/option_validator.rb', line 30 def @@valid_options end |
.valid?(option) ⇒ Boolean
Does the check to see if the option is valid. It checks the valid_options array (see above), checks if the start of the option name is in the plugin list or checks if it’s an theme_advanced_container setting
22 23 24 25 26 27 |
# File 'lib/tiny_mce/option_validator.rb', line 22 def valid?(option) option = option.to_s @@valid_options.include?(option) || (plugins && plugins.include?(option.split('_')[0])) || option =~ /^theme_advanced_container_\w+$/ end |