Class: Rails::Redactorjs::Configuration
- Inherits:
-
Object
- Object
- Rails::Redactorjs::Configuration
- Defined in:
- lib/rails-redactorjs/configuration.rb
Defined Under Namespace
Classes: Function
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options) ⇒ Configuration
constructor
A new instance of Configuration.
- #load(filename) ⇒ Object
- #merge(options) ⇒ Object
- #options_for_redactorjs ⇒ Object
Constructor Details
#initialize(options) ⇒ Configuration
Returns a new instance of Configuration.
18 19 20 |
# File 'lib/rails-redactorjs/configuration.rb', line 18 def initialize() @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
16 17 18 |
# File 'lib/rails-redactorjs/configuration.rb', line 16 def @options end |
Class Method Details
.defaults ⇒ Object
10 11 12 13 14 |
# File 'lib/rails-redactorjs/configuration.rb', line 10 def self.defaults { } end |
.load(filename) ⇒ Object
46 47 48 49 50 |
# File 'lib/rails-redactorjs/configuration.rb', line 46 def self.load(filename) config = new(defaults) config.load(filename) if File.exists?(filename) config end |
Instance Method Details
#load(filename) ⇒ Object
42 43 44 |
# File 'lib/rails-redactorjs/configuration.rb', line 42 def load(filename) .merge!(YAML::load(ERB.new(IO.read(filename)).result)) end |
#merge(options) ⇒ Object
38 39 40 |
# File 'lib/rails-redactorjs/configuration.rb', line 38 def merge() self.class.new(self..merge()) end |
#options_for_redactorjs ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/rails-redactorjs/configuration.rb', line 22 def result = {} .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 result end |