Module: GraphStarter::ApplicationHelper

Defined in:
app/helpers/graph_starter/application_helper.rb

Instance Method Summary collapse

Instance Method Details

#asset_path(asset) ⇒ Object



3
4
5
# File 'app/helpers/graph_starter/application_helper.rb', line 3

def asset_path(asset)
  super(id: asset, model_slug: asset.class.model_slug)
end

#configObject



19
20
21
# File 'app/helpers/graph_starter/application_helper.rb', line 19

def config
  GraphStarter::CONFIG
end

#engine_view {|eval("__FILE__.gsub(Rails.root.to_s, GraphStarter::Engine.root.to_s)",b.binding)| ... } ⇒ Object

Yields:



7
8
9
# File 'app/helpers/graph_starter/application_helper.rb', line 7

def engine_view(&b)
   yield eval("__FILE__.gsub(Rails.root.to_s, GraphStarter::Engine.root.to_s)",b.binding) 
end

#present_asset(object) {|AssetPresenter.new(object, self)| ... } ⇒ Object

Yields:



23
24
25
# File 'app/helpers/graph_starter/application_helper.rb', line 23

def present_asset(object)
  yield(AssetPresenter.new(object, self)) if block_given?
end

#render_body(asset, model_slug) ⇒ Object



11
12
13
14
15
16
17
# File 'app/helpers/graph_starter/application_helper.rb', line 11

def render_body(asset, model_slug)
  views = Dir.glob(Rails.root.join("app/views/#{model_slug}/_body.html.*"))

  partial_path = views.present? ? "#{model_slug}/body" : 'body'

  render partial: partial_path, locals: {asset: asset}
end