code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
module ActiveScaffold::Config
class Core < Base
def initialize_with_calendar_date_select(model_id)
initialize_without_calendar_date_select(model_id)
calendar_date_select_fields = self.model.columns.collect{|c| c.name.to_sym if [:date, :datetime].include?(c.type) }.compact
# check ... | Ruby |
module ActiveScaffold
def self.bridge(name, &block)
ActiveScaffold::Bridge.new(name, &block)
end
class Bridge
attr_accessor :name
cattr_accessor :bridges
cattr_accessor :bridges_run
self.bridges = []
def initialize(name, &block)
self.name = name
@install = nil
# b... | Ruby |
# This module attempts to create permissions conventions for your ActiveRecord models. It supports english-based
# methods that let you restrict access per-model, per-record, per-column, per-action, and per-user. All at once.
#
# You may define instance methods in the following formats:
# def #{column}_authorized_for_... | Ruby |
module ActiveScaffold::DataStructures
# encapsulates the column sorting configuration for the List view
class Sorting
include Enumerable
def initialize(columns)
@columns = columns
@clauses = []
end
# add a clause to the sorting, assuming the column is sortable
def add(column_name, ... | Ruby |
module ActiveScaffold::DataStructures
class ActionLinks
include Enumerable
def initialize
@set = []
end
# adds an ActionLink, creating one from the arguments if need be
def add(action, options = {})
link = action.is_a?(ActiveScaffold::DataStructures::ActionLink) ? action : ActiveScaf... | Ruby |
module ActiveScaffold::DataStructures
class Columns
include Enumerable
include ActiveScaffold::Configurable
# The motivation for this collection is that this Columns data structure fills two roles: it provides
# the master list of all known columns, and it provides an inheritable list for all other a... | Ruby |
module ActiveScaffold::DataStructures
class Set
include Enumerable
include ActiveScaffold::Configurable
attr_writer :label
def label
as_(@label)
end
def initialize(*args)
@set = []
self.add *args
end
# the way to add items to the set.
def add(*args)
args.... | Ruby |
module ActiveScaffold::DataStructures
class Column
include ActiveScaffold::Configurable
attr_reader :active_record_class
# this is the name of the getter on the ActiveRecord model. it is the only absolutely required attribute ... all others will be inferred from this name.
attr_accessor :name
#... | Ruby |
module ActiveScaffold::DataStructures
# A set of columns. These structures can be nested for organization.
class ActionColumns < Set
include ActiveScaffold::Configurable
# this lets us refer back to the action responsible for this link, if it exists.
# the immediate need here is to get the crud_type so... | Ruby |
class ActiveScaffold::DataStructures::Actions
include Enumerable
def initialize(*args)
@set = []
self.add *args
end
def exclude(*args)
args.collect! { |a| a.to_sym } # symbolize the args
@set.reject! { |m| args.include? m } # reject all actions specified
end
def add(*args)
args.each {... | Ruby |
module ActiveScaffold::DataStructures
class ActionLink
# provides a quick way to set any property of the object from a hash
def initialize(action, options = {})
# set defaults
self.action = action.to_s
self.label = action.to_s
self.confirm = false
self.type = :table
self.in... | Ruby |
module ActiveScaffold::DataStructures
# Wrapper for error strings so that they may be exported using to_xxx
class ErrorMessage
def initialize(error)
@error = error
end
def public_attributes
{ :error => @error }
end
def to_xml
public_attributes.to_xml(:root => "errors")
en... | Ruby |
require File.join(File.dirname(__FILE__), '../test_helper.rb')
class ArrayTest < Test::Unit::TestCase
def test_after
@sequence = ['a', 'b', 'c']
assert_equal 'b', @sequence.after('a')
assert_equal 'c', @sequence.after('b')
assert_equal 'a', @sequence.after('c')
assert_equal nil, @sequence.after(... | Ruby |
require File.join(File.dirname(__FILE__), '../test_helper.rb')
class PermissionModel < ActiveRecord::Base
def self.columns; [] end
def authorized_for_read?; true; end
def authorized_for_update?; false; end
#def authorized_for_create?; end
def a1_authorized?; true; end
def a2_authorized?; false; end
#de... | Ruby |
class ConstMocker
def initialize(*const_names)
@const_names = const_names
@const_states = {}
@const_names.each{|const_name|
@const_states[const_name] = Object.const_defined?(const_name) ? Object.const_get(const_name) : nil
}
end
def remove
@const_names.each{|const_name|
Object.s... | Ruby |
class ModelStub < ActiveRecord::Base
abstract_class = true
has_one :other_model, :class_name => 'ModelStub'
has_many :other_models, :class_name => 'ModelStub'
cattr_accessor :stubbed_columns
self.stubbed_columns = [:a, :b, :c, :d, :id]
attr_accessor *self.stubbed_columns
def other_model=(val)
@oth... | Ruby |
test_folders = %w[bridges config data_structures extensions misc]
all_tests = test_folders.inject([]) {|output, folder|
output + Dir[File.join(File.dirname(__FILE__), "#{folder}/**/*.rb")]
}
all_tests.each{|filename|
require filename
} | Ruby |
require 'test/unit'
require File.expand_path(File.join(File.dirname(__FILE__), '../../../../config/environment.rb'))
for file in %w[model_stub const_mocker]
require File.join(File.dirname(__FILE__), file)
end
ModelStub.connection.instance_eval do
def quote_column_name(name)
name
end
end | Ruby |
##
## Initialize the environment
##
require File.dirname(__FILE__) + '/environment'
##
## Run the install assets script, too, just to make sure
## But at least rescue the action in production
##
begin
require File.dirname(__FILE__) + '/install_assets'
rescue
raise $! unless RAILS_ENV == 'production'
end
| Ruby |
require 'rake'
require 'rake/testtask'
require 'rake/packagetask'
require 'rake/rdoctask'
require 'find'
desc 'Default: run unit tests.'
task :default => :test
desc 'Test ActiveScaffold.'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end
desc 'Generate docume... | Ruby |
require 'exceptions'
##
## Check for dependencies
##
version = Rails::VERSION::STRING.split(".")
if version[0] < "1" or (version[0] == "1" and version[1] < "2")
message = <<-EOM
************************************************************************
Rails 1.2.1 or greater is required. Please remove ActiveSc... | Ruby |
# Workaround a problem with script/plugin and http-based repos.
# See http://dev.rubyonrails.org/ticket/8189
Dir.chdir(Dir.getwd.sub(/vendor.*/, '')) do
##
## Copy over asset files (javascript/css/images) from the plugin directory to public/
##
def copy_files(source_path, destination_path, directory)
sourc... | Ruby |
##
## Delete public asset files
##
require 'fileutils'
directory = File.dirname(__FILE__)
[ :stylesheets, :javascripts, :images].each do |asset_type|
path = File.join(directory, "../../../public/#{asset_type}/active_scaffold")
FileUtils.rm_r(path)
end | Ruby |
##
## Install ActiveScaffold assets into /public
##
require File.dirname(__FILE__) + '/install_assets'
##
## Install Counter
##
#
# What's going on here?
# We're incrementing a web counter so we can track SVN installs of ActiveScaffold
#
# How?
# We're making a GET request to errcount.com to up... | Ruby |
module ActiveScaffold::Config
class Core < Base
# global level configuration
# --------------------------
# provides read/write access to the global Actions DataStructure
cattr_reader :actions
def self.actions=(val)
@@actions = ActiveScaffold::DataStructures::Actions.new(*val)
end
s... | Ruby |
module ActiveScaffold::Config
class Delete < Base
self.crud_type = :destroy
def initialize(core_config)
@core = core_config
# start with the ActionLink defined globally
@link = self.class.link.clone
end
# global level configuration
# --------------------------
# the Actio... | Ruby |
module ActiveScaffold::Config
class Subform < Base
def initialize(core_config)
@core = core_config
end
# global level configuration
# --------------------------
# instance-level configuration
# ----------------------------
# provides access to the list of columns specifically mean... | Ruby |
module ActiveScaffold::Config
class Create < Form
self.crud_type = :create
def initialize(*args)
super
self.persistent = self.class.persistent
end
# global level configuration
# --------------------------
# the ActionLink for this action
def self.link
@@link
end
... | Ruby |
module ActiveScaffold::Config
class Nested < Base
self.crud_type = :read
def initialize(core_config)
@core = core_config
end
# global level configuration
# --------------------------
cattr_accessor :shallow_delete
@@shallow_delete = false
# instance-level configuration
# -... | Ruby |
module ActiveScaffold::Config
class Update < Form
self.crud_type = :update
# global level configuration
# --------------------------
# the ActionLink for this action
def self.link
@@link
end
def self.link=(val)
@@link = val
end
@@link = ActiveScaffold::DataStructures::... | Ruby |
module ActiveScaffold::Config
class FieldSearch < Base
self.crud_type = :read
def initialize(core_config)
@core = core_config
@full_text_search = self.class.full_text_search?
# start with the ActionLink defined globally
@link = self.class.link.clone
end
# global level conf... | Ruby |
module ActiveScaffold::Config
class Show < Base
self.crud_type = :read
def initialize(core_config)
@core = core_config
# start with the ActionLink defined globally
@link = self.class.link.clone
end
# global level configuration
# --------------------------
cattr_accessor :l... | Ruby |
module ActiveScaffold::Config
class List < Base
self.crud_type = :read
def initialize(core_config)
@core = core_config
# inherit from global scope
# full configuration path is: defaults => global table => local table
@per_page = self.class.per_page
# originates here
@sor... | Ruby |
module ActiveScaffold::Config
class Search < Base
self.crud_type = :read
def initialize(core_config)
@core = core_config
@full_text_search = self.class.full_text_search?
# start with the ActionLink defined globally
@link = self.class.link.clone
end
# global level configura... | Ruby |
module ActiveScaffold::Config
class Form < Base
def initialize(core_config)
@core = core_config
# start with the ActionLink defined globally
@link = self.class.link.clone
# no global setting here because multipart should only be set for specific forms
@multipart = false
end
... | Ruby |
module ActiveScaffold::Config
class Base
include ActiveScaffold::Configurable
extend ActiveScaffold::Configurable
def self.inherited(subclass)
class << subclass
# the crud type of the action. possible values are :create, :read, :update, :destroy, and nil.
# this is not a setting for... | Ruby |
module ActiveScaffold::Config
class LiveSearch < Base
self.crud_type = :read
def initialize(core_config)
@core = core_config
@full_text_search = self.class.full_text_search?
# start with the ActionLink defined globally
@link = self.class.link.clone
end
# global level confi... | Ruby |
# save and validation support for associations.
class ActiveRecord::Base
def associated_valid?
# using [].all? syntax to avoid a short-circuit
with_unsaved_associated { |a| [a.valid?, a.associated_valid?].all? {|v| v == true} }
end
def save_associated
with_unsaved_associated { |a| a.save and a.save_a... | Ruby |
# The view_paths functionality in Edge Rails (Rails 2.0) doesn't support
# the idea of a fallback generic template file, such as what make ActiveScaffold
# work. This patch adds generic_view_paths, which are folders containing templates
# that may apply to all controllers.
#
# There is one major difference with generic... | Ruby |
class Object
def as_(string_to_localize, *args)
args.empty? ? string_to_localize : (sprintf string_to_localize, *args)
end
end
| Ruby |
module ActionView
module Helpers
class InstanceTag
# patch an issue with integer size parameters
def to_text_area_tag(options = {})
options = DEFAULT_TEXT_AREA_OPTIONS.merge(options.stringify_keys)
add_default_name_and_id(options)
if size = options.delete("size")
opt... | Ruby |
class ActionController::Routing::RouteSet
def generate_with_nil_id_awareness(*args)
args[0].delete(:id) if args[0][:id].nil?
generate_without_nil_id_awareness(*args)
end
alias_method_chain :generate, :nil_id_awareness
end | Ruby |
##
## Add MIME type for JSON (backwards compat)
##
unless Mime.const_defined?(:JSON)
# Rails 1.1 Method
# Register a new Mime::Type
Mime::JSON = Mime::Type.new 'application/json', :json, %w( text/json )
Mime::LOOKUP["application/json"] = Mime::JSON
Mime::LOOKUP["text/json"] = Mime::JSON
# Its default handl... | Ruby |
# wrap the action rendering for ActiveScaffold controllers
module ActionController #:nodoc:
class Base
def render_with_active_scaffold(*args, &block)
if self.class.uses_active_scaffold? and params[:adapter] and @rendering_adapter.nil?
@rendering_adapter = true # recursion control
# if we nee... | Ruby |
class Array
# returns the value after the given value. wraps around. defaults to first element in array.
def after(value)
return nil unless include? value
self[(index(value).to_i + 1) % length]
end
end | Ruby |
# the ever-useful to_label method
class ActiveRecord::Base
def to_label
[:name, :label, :title, :to_s].each do |attribute|
return send(attribute) if respond_to?(attribute) and send(attribute).is_a?(String)
end
end
end
| Ruby |
module ActionController
module Resources
class Resource
ACTIVE_SCAFFOLD_ROUTING = {
:collection => {:show_search => :get, :update_table => :get, :edit_associated => :get, :list => :get, :new_existing => :get},
:member => {:row => :get, :nested => :get, :edit_associated => :get, :add_associat... | Ruby |
# wrap the action rendering for ActiveScaffold views
module ActionView #:nodoc:
class Base
# Adds two rendering options.
#
# ==render :super
#
# This syntax skips all template overrides and goes directly to the provided ActiveScaffold templates.
# Useful if you want to wrap an existing templat... | Ruby |
# a simple (manual) unsaved? flag and method. at least it automatically reverts after a save!
class ActiveRecord::Base
# acts like a dirty? flag, manually thrown during update_record_from_params.
def unsaved=(val)
@unsaved = (val) ? true : false
end
# whether the unsaved? flag has been thrown
def unsaved... | Ruby |
module ActiveRecord
class Errors
# uses config.columns[attr].label instead of attr.humanize, for improved consistency in form feedback.
# also passes strings through as_(), since it's handy.
def as_full_messages(config)
@as_config = config
full_messages = []
@errors.each_key do |attr|
... | Ruby |
module ActionController #:nodoc:
module Components
module InstanceMethods
# Extracts the action_name from the request parameters and performs that action.
private
# This is to fix a bug in Rails. 1.2.2 was calling klass.controller_name instead of klass.controller_path, which was in turn settin... | Ruby |
# Apply patch (http://dev.rubyonrails.org/changeset/6343) that is already in edge, soon to be 1.2.4
# Allow array and hash query parameters. Array route parameters are converted/to/a/path as before. #6765, #7047, #7462 [bgipsy, Jeremy McAnally, Dan Kubb, brendan]
module ActionController
module Routing
class Rout... | Ruby |
module ActiveRecord
module Reflection
class AssociationReflection #:nodoc:
def reverse_for?(klass)
reverse_matches_for(klass).empty? ? false : true
end
attr_writer :reverse
def reverse
unless @reverse
reverse_matches = reverse_matches_for(self.class_nam... | Ruby |
require 'forwardable'
class Paginator
VERSION = '1.0.9'
class ArgumentError < ::ArgumentError; end
class MissingCountError < ArgumentError; end
class MissingSelectError < ArgumentError; end
attr_reader :per_page, :count
# Instantiate a new Paginator object
#
# Provide:
# * A total count ... | Ruby |
# Matt Mower <matt@cominded.com>
#
# A base class for creating DHTML confirmation types.
#
# The real work is done by the onclick_function and onclick_handler methods. In
# general it should only be required to override the default onclick_handler
# method and provide the specific Javascript required to invoke the DHT... | Ruby |
module ActiveScaffold
def self.included(base)
base.extend(ClassMethods)
base.module_eval do
# TODO: these should be in actions/core
before_filter :handle_user_settings
end
end
def self.set_defaults(&block)
ActiveScaffold::Config::Core.configure &block
end
def active_... | Ruby |
module ActionView
module Helpers
module FormOptionsHelper
# Return a full select and option tags for the given object and method, using usa_state_options_for_select to generate the list of option <tags>.
def usa_state_select(object, method, priority_states = nil, options = {}, html_options = {})
... | Ruby |
module ActiveScaffold
module Helpers
# A bunch of helper methods to produce the common view ids
module Ids
def controller_id
@controller_id ||= (params[:parent_controller] || params[:controller]).gsub("/", "__")
end
def active_scaffold_id
"#{controller_id}-active-sc... | Ruby |
module ActiveScaffold
module Helpers
# Helpers that assist with the rendering of a Form Column
module FormColumns
# This method decides which input to use for the given column.
# It does not do any rendering. It only decides which method is responsible for rendering.
def active_scaffold_inpu... | Ruby |
module ActiveScaffold
module Helpers
module Associations
# Provides a way to honor the :conditions on an association while searching the association's klass
def association_options_find(association, conditions = nil)
association.klass.find(:all, :conditions => controller.send(:merge_conditions... | Ruby |
module ActiveScaffold
module Helpers
# All extra helpers that should be included in the View.
# Also a dumping ground for uncategorized helpers.
module ViewHelpers
include ActiveScaffold::Helpers::Ids
include ActiveScaffold::Helpers::Associations
include ActiveScaffold::Helpers::P... | Ruby |
module ActiveScaffold
module Helpers
module ControllerHelpers
include ActiveScaffold::Helpers::Ids
end
end
end | Ruby |
module ActiveScaffold
module Helpers
module Pagination
def pagination_ajax_link(page_number, params)
page_link = link_to_remote(page_number,
{ :url => params.merge(:page => page_number),
:after => "$('#{loading_indicator_id(:action => :pagination)}').style.visib... | Ruby |
module ActiveScaffold
module Helpers
# Helpers that assist with the rendering of a List Column
module ListColumns
def get_column_value(record, column)
# check for an override helper
value = if column_override? column
# we only pass the record as the argument. we previously also... | Ruby |
module ActiveScaffold
module Constraints
def self.included(base)
base.module_eval do
before_filter :register_constraints_with_action_columns
end
end
protected
# Returns the current constraints
def active_scaffold_constraints
return active_scaffold_session_storage[:const... | Ruby |
module ActiveScaffold
# Provides support for param hashes assumed to be model attributes.
# Support is primarily needed for creating/editing associated records using a nested hash structure.
#
# Paradigm Params Hash (should write unit tests on this):
# params[:record] = {
# # a simple record attribute... | Ruby |
module ActiveScaffold::Actions
module Core
def self.included(base)
base.class_eval do
after_filter :clear_flashes
end
end
protected
def authorized_for?(*args)
active_scaffold_config.model.authorized_for?(*args)
end
def clear_flashes
if request.xhr?
fl... | Ruby |
module ActiveScaffold::Actions
module Delete
def self.included(base)
base.before_filter :delete_authorized?, :only => [:delete, :destroy]
end
# this method is for html mode. it provides "the missing action" (http://thelucid.com/articles/2006/07/26/simply-restful-the-missing-action).
# it also g... | Ruby |
module ActiveScaffold::Actions
module Subform
def edit_associated
@parent_record = params[:id].nil? ? active_scaffold_config.model.new : find_if_allowed(params[:id], :update)
@column = active_scaffold_config.columns[params[:association]]
# NOTE: we don't check whether the user is allowed to upd... | Ruby |
module ActiveScaffold::Actions
module Create
def self.included(base)
base.before_filter :create_authorized?, :only => [:new, :create]
base.verify :method => :post,
:only => :create,
:redirect_to => { :action => :index }
end
def new
do_new
respo... | Ruby |
module ActiveScaffold::Actions
# The Nested module basically handles automatically linking controllers together. It does this by creating column links with the right parameters, and by providing any supporting systems (like a /:controller/nested action for returning associated scaffolds).
module Nested
def... | Ruby |
module ActiveScaffold::Actions
module Update
def self.included(base)
base.before_filter :update_authorized?, :only => [:edit, :update]
base.verify :method => [:post, :put],
:only => :update,
:redirect_to => { :action => :index }
end
def edit
do_edit
... | Ruby |
module ActiveScaffold::Actions
module FieldSearch
def self.included(base)
base.before_filter :field_search_authorized?, :only => :show_search
base.before_filter :do_search
end
# FieldSearch uses params[:search] and not @record because search conditions do not always pass the Model's validatio... | Ruby |
module ActiveScaffold::Actions
module Show
def self.included(base)
base.before_filter :show_authorized?, :only => :show
end
def show
do_show
successful?
respond_to do |type|
type.html { render :action => 'show', :layout => true }
type.js { render :partial => 'show... | Ruby |
module ActiveScaffold::Actions
module List
def self.included(base)
base.before_filter :list_authorized?, :only => [:index, :table, :update_table, :row, :list]
end
def index
list
end
def table
do_list
render(:action => 'list', :layout => false)
end
# This is calle... | Ruby |
module ActiveScaffold::Actions
module Search
def self.included(base)
base.before_filter :search_authorized?, :only => :show_search
base.before_filter :do_search
end
def show_search
respond_to do |type|
type.html { render(:action => "search") }
type.js { render(:partial =... | Ruby |
module ActiveScaffold::Actions
module LiveSearch
def self.included(base)
base.before_filter :live_search_authorized?, :only => :show_search
base.before_filter :do_search
end
def show_search
respond_to do |type|
type.html do
if successful?
render(:partial =>... | Ruby |
# Copyright (c) 2006 Sean Treadway
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish... | Ruby |
module ActiveScaffold
class ControllerNotFound < RuntimeError; end
class DependencyFailure < RuntimeError; end
class MalformedConstraint < RuntimeError; end
class RecordNotAllowed < SecurityError; end
class ReverseAssociationRequired < RuntimeError; end
end
| Ruby |
module ActiveScaffold
# Exposes a +configure+ method that accepts a block and runs all contents of the block in two contexts, as opposed to the normal one. First, everything gets evaluated as part of the object including Configurable. Then, as a failover, missing methods and variables are evaluated in the original bi... | Ruby |
module ActiveScaffold
module Finder
# Takes a collection of search terms (the tokens) and creates SQL that
# searches all specified ActiveScaffold columns. A row will match if each
# token is found in at least one of the columns.
def self.create_conditions_for_columns(tokens, columns, like_pattern = '... | Ruby |
ActiveScaffold.bridge "FileColumn" do
install do
if ActiveScaffold::Config::Core.instance_methods.include?("initialize_with_file_column")
raise RuntimeError, "We've detected that you have active_scaffold_file_column_bridge installed. This plugin has been moved to core. Please remove active_scaffold_file_c... | Ruby |
module FileColumnHelpers
class << self
def file_column_fields(klass)
klass.instance_methods.grep(/_just_uploaded\?$/).collect{|m| m[0..-16].to_sym }
end
def generate_delete_helpers(klass)
file_column_fields(klass).each { |field|
klass.send :class_eval, <<-EOF, __FILE__, __LINE__ +... | Ruby |
module ActiveScaffold::DataStructures
class Column
attr_accessor :file_column_display
end
end
module ActiveScaffold::Config
class Core < Base
attr_accessor :file_column_fields
def initialize_with_file_column(model_id)
initialize_without_file_column(model_id)
return unle... | Ruby |
module ActiveScaffold
module Helpers
# Helpers that assist with the rendering of a List Column
module ListColumns
def active_scaffold_column_download_link_with_filename(column, record)
return nil if record.send(column.name).nil?
active_scaffold_column_download_link(column, record, File.b... | Ruby |
module ActiveScaffold
module Helpers
# Helpers that assist with the rendering of a Form Column
module FormColumns
def active_scaffold_input_file_column(column, options)
if @record.send(column.name)
# we already have a value? display the form for deletion.
content_tag(
... | Ruby |
class MockModel
attr_accessor :name
attr_accessor :bio
attr_accessor :band_image
attr_accessor :band_image_just_uploaded
def band_image_just_uploaded?; self.band_image_just_uploaded ? true : false; end
end | Ruby |
require 'test/unit'
require "rubygems"
require 'active_support'
for file in ["../lib/delete_file_column.rb", "mock_model.rb"]
require File.expand_path(File.join(File.dirname(__FILE__), file))
end
def dbg
require 'ruby-debug'
Debugger.start
debugger
end
| Ruby |
ActiveScaffold.bridge "CalendarDateSelect" do
install do
# check to see if the old bridge was installed. If so, warn them
# we can detect this by checking to see if the bridge was installed before calling this code
if ActiveScaffold::Config::Core.instance_methods.include?("initialize_with_calendar_date_s... | Ruby |
module ActiveScaffold::Config
class Core < Base
def initialize_with_calendar_date_select(model_id)
initialize_without_calendar_date_select(model_id)
calendar_date_select_fields = self.model.columns.collect{|c| c.name.to_sym if [:date, :datetime].include?(c.type) }.compact
# check ... | Ruby |
module ActiveScaffold
def self.bridge(name, &block)
ActiveScaffold::Bridge.new(name, &block)
end
class Bridge
attr_accessor :name
cattr_accessor :bridges
cattr_accessor :bridges_run
self.bridges = []
def initialize(name, &block)
self.name = name
@install = nil
# b... | Ruby |
# This module attempts to create permissions conventions for your ActiveRecord models. It supports english-based
# methods that let you restrict access per-model, per-record, per-column, per-action, and per-user. All at once.
#
# You may define instance methods in the following formats:
# def #{column}_authorized_for_... | Ruby |
module ActiveScaffold::DataStructures
# encapsulates the column sorting configuration for the List view
class Sorting
include Enumerable
def initialize(columns)
@columns = columns
@clauses = []
end
# add a clause to the sorting, assuming the column is sortable
def add(column_name, ... | Ruby |
module ActiveScaffold::DataStructures
class ActionLinks
include Enumerable
def initialize
@set = []
end
# adds an ActionLink, creating one from the arguments if need be
def add(action, options = {})
link = action.is_a?(ActiveScaffold::DataStructures::ActionLink) ? action : ActiveScaf... | Ruby |
module ActiveScaffold::DataStructures
class Columns
include Enumerable
include ActiveScaffold::Configurable
# The motivation for this collection is that this Columns data structure fills two roles: it provides
# the master list of all known columns, and it provides an inheritable list for all other a... | Ruby |
module ActiveScaffold::DataStructures
class Set
include Enumerable
include ActiveScaffold::Configurable
attr_writer :label
def label
as_(@label)
end
def initialize(*args)
@set = []
self.add *args
end
# the way to add items to the set.
def add(*args)
args.... | Ruby |
module ActiveScaffold::DataStructures
class Column
include ActiveScaffold::Configurable
attr_reader :active_record_class
# this is the name of the getter on the ActiveRecord model. it is the only absolutely required attribute ... all others will be inferred from this name.
attr_accessor :name
#... | Ruby |
module ActiveScaffold::DataStructures
# A set of columns. These structures can be nested for organization.
class ActionColumns < Set
include ActiveScaffold::Configurable
# this lets us refer back to the action responsible for this link, if it exists.
# the immediate need here is to get the crud_type so... | Ruby |
class ActiveScaffold::DataStructures::Actions
include Enumerable
def initialize(*args)
@set = []
self.add *args
end
def exclude(*args)
args.collect! { |a| a.to_sym } # symbolize the args
@set.reject! { |m| args.include? m } # reject all actions specified
end
def add(*args)
args.each {... | Ruby |
module ActiveScaffold::DataStructures
class ActionLink
# provides a quick way to set any property of the object from a hash
def initialize(action, options = {})
# set defaults
self.action = action.to_s
self.label = action.to_s
self.confirm = false
self.type = :table
self.in... | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.