Sha256: 3818904b276af246fdeb6afb57ee4fb112f80452079df272a8b4ee1d3159095c
Contents?: true
Size: 1.63 KB
Versions: 13
Compression:
Stored size: 1.63 KB
Contents
module Spud::BelongsToApp extend ActiveSupport::Concern included do extend ClassMethods end # class Config # attr_reader :page_application # attr_reader :page_thumbnail # def initialize(app,thumb) # @page_application = app # @page_thumbnail = thumb # end # end module ClassMethods def belongs_to_spud_app(name=nil,options={}) @page_title = options[:page_title] Spud::Core.admin_applications.each do |app| if app[:name].parameterize.underscore.to_sym == name @page_application = app break end end self.class_eval do before_filter { |controller| @page_thumbnail = self.class.page_application[:thumbnail] @page_name = self.class.page_title if current_user.super_admin == false permission = current_user_permissions.select{|perm| perm.name == @page_name} if permission.blank? flash[:error] = "You do not have access to this area." redirect_to spud_admin_root_url and return end end if controller.action_name == 'new' || controller.action_name == 'create' @page_name = "New #{@page_name.singularize}" elsif controller.action_name == 'edit' || controller.action_name == 'update' @page_name = "Edit #{@page_name.singularize}" elsif controller.action_name == 'show' @page_name = "Show #{@page_name.singularize}" end } end end def page_application @page_application || self.superclass.instance_variable_get('@page_application') end def page_title @page_title || self.superclass.instance_variable_get('@page_title') || page_application[:name] end end end
Version data entries
13 entries across 13 versions & 1 rubygems