Module: ScaffoldingExtensions

Defined in:
lib/scaffolding_extensions.rb,
lib/scaffolding_extensions/helper.rb,
lib/scaffolding_extensions/controller.rb,
lib/scaffolding_extensions/overridable.rb,
lib/scaffolding_extensions/jquery_helper.rb,
lib/scaffolding_extensions/controller/rack.rb,
lib/scaffolding_extensions/meta_controller.rb,
lib/scaffolding_extensions/prototype_helper.rb,
lib/scaffolding_extensions/controller/ramaze.rb,
lib/scaffolding_extensions/controller/camping.rb,
lib/scaffolding_extensions/controller/sinatra.rb,
lib/scaffolding_extensions/controller/action_controller.rb

Overview

This is the base module for the plugin. It has some constants that can be changed:

  • TEMPLATE_DIR - the directory with the scaffold templates

  • DEFAULT_METHODS - the default methods added by the scaffolding

If you include the contents of auto_complete.css in your stylesheet, set “auto_complete_skip_style = true”, so the stylesheet isn’t added for every autocompleting text box.

Scaffolding Extensions attempts to determine which framework/ORM you are using and load the support for it (if it is supported).

Defined Under Namespace

Modules: ActionController, ActionControllerHelper, ActiveRecord, CampingController, CampingHelper, Controller, DataMapper, Helper, JQueryHelper, MetaActionController, MetaActiveRecord, MetaCampingController, MetaController, MetaDataMapper, MetaModel, MetaOverridable, MetaRamazeController, MetaSequel, MetaSinatraController, Model, Overridable, PrototypeHelper, RamazeController, Sequel, SinatraController, SinatraHelper Classes: RackController

Constant Summary collapse

AUTO_COMPLETE_CSS =
<<-END
  <style type='text/css'>
    div.auto_complete {
      width: 350px;
      background: #fff;
    }
    div.auto_complete ul {
      border:1px solid #888;
      margin:0;
      padding:0;
      width:100%;
      list-style-type:none;
    }
    div.auto_complete ul li {
      margin:0;
      padding:3px;
    }
    div.auto_complete ul li.selected { 
      background-color: #ffb; 
    }
    div.auto_complete ul strong.highlight { 
      color: #800; 
      margin:0;
      padding:0;
    }
  </style>
END
ROOT =
File.dirname(File.dirname(__FILE__))
TEMPLATE_DIR =
File.join(ROOT, "scaffolds")
DEFAULT_ACTION =
:browse
DEFAULT_METHODS =
[:manage, :show, :delete, :edit, :new, :search, :merge, :browse]
MODEL_SUPERCLASSES =
[]

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.all_models(options = {}) ⇒ Object

Takes two options, :only and :except. If :only is given, :except is ignored. Either can contain model classes or underscored model name strings.



57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/scaffolding_extensions.rb', line 57

def all_models(options={})
  return @all_models if @all_models
  if options[:only]
    Array(options[:only]).collect{|f| f.is_a?(String) ? f.camelize.constantize : f}
  else
    string_except, except = Array(options[:except]).partition{|f| f.is_a?(String)}
    model_files.collect{|file|File.basename(file).sub(/\.rb\z/, '')}.
     reject{|f| string_except.include?(f)}.
     map{|f| f.camelize.constantize}.
     reject{|m| except.include?(m) || !MODEL_SUPERCLASSES.any?{|klass| m.ancestors.include?(klass)}}
  end
end

.auto_complete_skip_styleObject

Returns the value of attribute auto_complete_skip_style.



52
53
54
# File 'lib/scaffolding_extensions.rb', line 52

def auto_complete_skip_style
  @auto_complete_skip_style
end

.model_files=(value) ⇒ Object

Sets the attribute model_files

Parameters:

  • value

    the value to set the attribute model_files to.



53
54
55
# File 'lib/scaffolding_extensions.rb', line 53

def model_files=(value)
  @model_files = value
end

Class Method Details

.auto_complete_cssObject

The stylesheet for the autocompleting text box, or the empty string if auto_complete_skip_style is true.



72
73
74
# File 'lib/scaffolding_extensions.rb', line 72

def auto_complete_css
  auto_complete_skip_style ? '' : AUTO_COMPLETE_CSS
end

.javascript_library=(jslib) ⇒ Object

The javascript library to use (defaults to JQuery, can be set to ‘Prototype’)



77
78
79
80
# File 'lib/scaffolding_extensions.rb', line 77

def javascript_library=(jslib)
  require "scaffolding_extensions/#{jslib.downcase}_helper"
  ScaffoldingExtensions::Helper.send(:include, const_get("#{jslib}Helper"))
end