Sha256: efcb542ae6b8a1b6e082b05c1a015da1f2eb4bcfd6958b54a6154df133cbf70a

Contents?: true

Size: 621 Bytes

Versions: 2

Compression:

Stored size: 621 Bytes

Contents

require 'd3c3-rails'

module D3C3Rails
  # Loads graphing helper methods into class
  module Grapher

    def self.included(base)
      D3C3Rails::Generators.instance_methods(false).each do |method|
        base.class_eval do

          def _grapher_holder
            @_grapher_holder ||= D3C3Rails::Holder.new
          end

          define_method method do |*args|
            _grapher_holder.context = self
            _grapher_holder.send(method, *args)
            _grapher_holder.grapher_flush.html_safe
          end

        end
      end

    end
  end
end

ActionView::Base.send(:include, D3C3Rails::Grapher)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
d3c3-rails-0.1.2 lib/d3c3-rails/grapher.rb
d3c3-rails-0.1.0 lib/d3c3-rails/grapher.rb