Module: GraphStarter::ApplicationHelper

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

Instance Method Summary collapse

Instance Method Details

#app_userObject



27
28
29
# File 'app/helpers/graph_starter/application_helper.rb', line 27

def app_user
  defined?(:current_user) ? current_user : nil
end

#app_user_is_admin?Boolean

Returns:

  • (Boolean)


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

def app_user_is_admin?
  current_user && current_user.respond_to?(:admin?) && current_user.admin?
end

#asset_path(asset) ⇒ Object



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

def asset_path(asset)
  graph_starter.asset_path(id: asset, model_slug: asset.class.model_slug)
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

#missing_image_tagObject



31
32
33
# File 'app/helpers/graph_starter/application_helper.rb', line 31

def missing_image_tag
  @missing_image_tag ||= image_tag 'missing'
end

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

Yields:



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

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