Sha256: 92754868dfe85634cf047cf42e249600dc79d1e57470facf8b4e9a757837c7af

Contents?: true

Size: 1.07 KB

Versions: 3

Compression:

Stored size: 1.07 KB

Contents

module ActsAsDashboard
  module InstanceMethods
    def show
      @json_widgets       = dashboard_config.widgets.map {|w| w.attributes}.to_json
      @dashboard_path     = '/' + self.class.to_s.underscore.sub('_controller', '').singularize + '/widgets/'

#     @dashboard_css_path = File.join(File.dirname(__FILE__), 'public', 'stylesheets', 'dashboard.css')
#     @dashboard_css      = File.open(@dashboard_css_path).read
#
#     @dashboard_js_path  = File.join(File.dirname(__FILE__), 'public', 'javascripts', 'dashboard.js')
#     @dashboard_js       = File.open(@dashboard_js_path).read

#     render :file => File.join(File.dirname(__FILE__), 'app', 'views', 'dashboards', 'show.html.erb')
    end
  end

  def widget_data
    name    = params[:path].first
    widget  = dashboard_config.find_widget name

    raise WidgetNotFound, %Q(No widget named "#{name}" found.) if widget.nil?

    render :text => widget.block.call
  end

  protected

    # Make the ActsAsDashboard::Config instance variable easily accessible.
    def dashboard_config
      self.class.dashboard_config
    end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
acts_as_dashboard-0.3.2 lib/acts_as_dashboard/instance_methods.rb
acts_as_dashboard-0.3.0 lib/acts_as_dashboard/instance_methods.rb
acts_as_dashboard-0.1.0 lib/acts_as_dashboard/instance_methods.rb