lib/highcharts/base.rb in highcharts-js-rails-0.2.1 vs lib/highcharts/base.rb in highcharts-js-rails-1.0.0

- old
+ new

@@ -1,7 +1,5 @@ -require 'rails' - class Highcharts class Base attr_reader :options, :default, :skip_quotation, :suboptions @@ -17,10 +15,11 @@ @options = {default => options} else raise ArgumentError, "You must pass a Hash to #{self.class}. You passed #{options.inspect}" end end + # If there is an option that is available as a suboption to the current class, # let's set the option to an instance of that subclass. options.each do |k, v| @options[k] = "Highcharts::#{suboptions[k]}".constantize.new(v) if suboptions.keys.include?(k) end @@ -39,14 +38,15 @@ (suboptions.keys.include?(k) && !v.is_a?(Array) ? '}' : '') end json.join(',') end - # This method is used in #to_json to remove the first and last characters from an option's value. - # In the end this removes the encapsulating quotation marks (") from a specific option, provided - # it is included in the current class's skip_quotation array. - def check_quotation(key, json) - skip_quotation.present? && Array.wrap(skip_quotation).include?(key) ? json[1..-2] : json - end + private + # This method is used in #to_json to remove the first and last characters from an option's value. + # In the end this removes the encapsulating quotation marks (") from a specific option, provided + # it is included in the current class's skip_quotation array. + def check_quotation(key, json) + skip_quotation.present? && Array.wrap(skip_quotation).include?(key) ? json[1..-2] : json + end end end