module ActiveScaffold
Public Class Methods
autoload_subdir(dir, mod=self, root = File.dirname(__FILE__))
click to toggle source
# File lib/active_scaffold.rb, line 24 def self.autoload_subdir(dir, mod=self, root = File.dirname(__FILE__)) Dir["#{root}/active_scaffold/#{dir}/*.rb"].each { |file| basename = File.basename(file, ".rb") mod.module_eval { autoload basename.camelcase.to_sym, "active_scaffold/#{dir}/#{basename}" } } end
default_view_paths(custom_paths = [])
click to toggle source
# File lib/active_scaffold.rb, line 148 def self.default_view_paths(custom_paths = []) default_paths = [] ActionController::Base.view_paths.each do |dir| active_scaffold_override_dir = File.join(dir.to_s,"active_scaffold_overrides") default_paths << active_scaffold_override_dir if File.exists?(active_scaffold_override_dir) end default_paths.uniq! default_paths.concat(custom_paths) unless custom_paths.nil? active_scaffold_default_frontend_path = File.join(ActiveScaffold::Config::Core.plugin_directory, 'frontends', 'default' , 'views') default_paths << active_scaffold_default_frontend_path default_paths end
exclude_bridges()
click to toggle source
# File lib/active_scaffold.rb, line 140 def self.exclude_bridges @@exclude_bridges ||= [] end
exclude_bridges=(bridges)
click to toggle source
exclude bridges you do not need name of bridge subdir should be used to exclude it eg
ActiveScaffold.exclude_bridges = [:cancan, :ancestry] if you are using Activescaffold as a gem add to initializer if you are using Activescaffold as a plugin add to active_scaffold_env.rb
# File lib/active_scaffold.rb, line 136 def self.exclude_bridges=(bridges) @@exclude_bridges = bridges end
included(base)
click to toggle source
# File lib/active_scaffold.rb, line 60 def self.included(base) base.extend(ClassMethods) base.module_eval do # TODO: these should be in actions/core before_filter :handle_user_settings before_filter :check_input_device end base.helper_method :touch_device? base.helper_method :hover_via_click? end
js_framework()
click to toggle source
# File lib/active_scaffold.rb, line 126 def self.js_framework @@js_framework ||= :jquery end
js_framework=(framework)
click to toggle source
# File lib/active_scaffold.rb, line 122 def self.js_framework=(framework) @@js_framework = framework end
root()
click to toggle source
# File lib/active_scaffold.rb, line 144 def self.root File.dirname(__FILE__) + "/.." end
set_defaults(&block)
click to toggle source
# File lib/active_scaffold.rb, line 72 def self.set_defaults(&block) ActiveScaffold::Config::Core.configure &block end
Public Instance Methods
active_scaffold_config()
click to toggle source
# File lib/active_scaffold.rb, line 76 def active_scaffold_config self.class.active_scaffold_config end
active_scaffold_config_for(klass)
click to toggle source
# File lib/active_scaffold.rb, line 80 def active_scaffold_config_for(klass) self.class.active_scaffold_config_for(klass) end
active_scaffold_session_storage(id = (params[:eid] || params[:controller]))
click to toggle source
# File lib/active_scaffold.rb, line 84 def active_scaffold_session_storage(id = (params[:eid] || params[:controller])) session_index = "as:#{id}" session[session_index] ||= {} session[session_index] end
check_input_device()
click to toggle source
# File lib/active_scaffold.rb, line 102 def check_input_device if self.class.uses_active_scaffold? if request.env["HTTP_USER_AGENT"] && request.env["HTTP_USER_AGENT"][/(iPhone|iPod|iPad)/i] session[:input_device_type] = 'TOUCH' session[:hover_supported] = false else session[:input_device_type] = 'MOUSE' session[:hover_supported] = true end if session[:input_device_type].nil? end end
handle_user_settings()
click to toggle source
at some point we need to pass the session and params into config. we'll just take care of that before any particular action occurs by passing those hashes off to the UserSettings class of each action.
# File lib/active_scaffold.rb, line 91 def handle_user_settings if self.class.uses_active_scaffold? active_scaffold_config.actions.each do |action_name| conf_instance = active_scaffold_config.send(action_name) rescue next next if conf_instance.class::UserSettings == ActiveScaffold::Config::Base::UserSettings # if it hasn't been extended, skip it active_scaffold_session_storage[action_name] ||= {} conf_instance.user = conf_instance.class::UserSettings.new(conf_instance, active_scaffold_session_storage[action_name], params) end end end
hover_via_click?()
click to toggle source
# File lib/active_scaffold.rb, line 118 def hover_via_click? session[:hover_supported] == false end
touch_device?()
click to toggle source
# File lib/active_scaffold.rb, line 114 def touch_device? session[:input_device_type] == 'TOUCH' end