Module: GoogleCharts::Helpers::ActionView

Defined in:
lib/google_charts/helpers/action_view.rb

Class Method Summary collapse

Class Method Details

.define_helper(name, options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/google_charts/helpers/action_view.rb', line 5

def self.define_helper( name, options = {} )
  helper_name = [options[:prefix], name, options[:suffix]||'chart'].compact.join( '_' )

  module_eval <<-DEF
    def #{helper_name}( *options )
      chart = GoogleCharts::Charts::#{name.to_s.capitalize}.new( self, *options )
      yield chart if block_given?

      concat chart.to_html
    end
  DEF
end