module Lolita::Controllers::InternalHelpers
Public Instance Methods
current_form(temp_form = nil) { || ... }
click to toggle source
# File lib/lolita/controllers/internal_helpers.rb, line 36 def current_form(temp_form = nil) if block_given? old_form = @current_form @current_form = temp_form content = yield @current_form = old_form end @current_form end
current_form=(form)
click to toggle source
# File lib/lolita/controllers/internal_helpers.rb, line 32 def current_form=(form) @current_form = form end
include_application_assets()
click to toggle source
# File lib/lolita/controllers/internal_helpers.rb, line 4 def include_application_assets result = '' Lolita.application.assets.each do |asset_name| if asset_name.match(/\.js(\.|$)/) result << javascript_include_tag(asset_name) elsif asset_name.match(/\.css(\.|$)/) result << stylesheet_link_tag(asset_name) end end raw(result) end
is_lolita_resource?()
click to toggle source
# File lib/lolita/controllers/internal_helpers.rb, line 59 def is_lolita_resource? fail ActionController::UnknownAction unless lolita_mapping true end
lolita_mapping(new_mapping = nil)
click to toggle source
# File lib/lolita/controllers/internal_helpers.rb, line 28 def lolita_mapping(new_mapping = nil) @lolita_mapping ||= request.env['lolita.mapping'] end
resource()
click to toggle source
# File lib/lolita/controllers/internal_helpers.rb, line 16 def resource instance_variable_get(:"@#{resource_name}") end
resource_class()
click to toggle source
# File lib/lolita/controllers/internal_helpers.rb, line 24 def resource_class lolita_mapping.to end
resource_name()
click to toggle source
# File lib/lolita/controllers/internal_helpers.rb, line 20 def resource_name lolita_mapping.class_name.gsub(/::/, '_').underscore.to_sym end
use_mapping(new_mapping) { || ... }
click to toggle source
# File lib/lolita/controllers/internal_helpers.rb, line 46 def use_mapping(new_mapping) if block_given? begin @old_mapping = lolita_mapping @lolita_mapping = new_mapping yield ensure @lolita_mapping = @old_mapping @old_mapping = nil end end end
Protected Instance Methods
resource=(new_resource)
click to toggle source
# File lib/lolita/controllers/internal_helpers.rb, line 66 def resource=(new_resource) instance_variable_set(:"@#{resource_name}", new_resource) end