module ActiveScaffold
Public Class Methods
autoload_subdir(dir, mod=self, root = File.dirname(__FILE__))
click to toggle source
# File lib/active_scaffold.rb, line 28 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
exclude_bridges()
click to toggle source
# File lib/active_scaffold.rb, line 142 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 138 def self.exclude_bridges=(bridges) @@exclude_bridges = bridges end
included(base)
click to toggle source
# File lib/active_scaffold.rb, line 64 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 128 def self.js_framework @@js_framework ||= :prototype end
js_framework=(framework)
click to toggle source
# File lib/active_scaffold.rb, line 124 def self.js_framework=(framework) @@js_framework = framework end
root()
click to toggle source
# File lib/active_scaffold.rb, line 146 def self.root File.dirname(__FILE__) + "/.." end
set_defaults(&block)
click to toggle source
# File lib/active_scaffold.rb, line 76 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 80 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 84 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 88 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 106 def check_input_device 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
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 95 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 120 def hover_via_click? session[:hover_supported] == false end
touch_device?()
click to toggle source
# File lib/active_scaffold.rb, line 116 def touch_device? session[:input_device_type] == 'TOUCH' end