class AutoForme::Framework

  1. lib/autoforme/framework.rb
Superclass: Object

The Framework class contains forms for a set of models, tied to web framework controller.

Attributes

controller [R]

The web framework controller tied to this framework.

model_classes [R]

A map of underlying model classes to AutoForme::Model classes for this Framework.

models [R]

A map of link names to AutoForme::Model classes for this Framework.

opts [R]

The configuration options related to this framework.

prefix [R]

The path prefix that this framework is mounted at

Public Class methods

for(type, controller, opts={}, &block)

See Autoforme.for.

[show source]
   # File lib/autoforme/framework.rb
10 def self.for(type, controller, opts={}, &block)
11   AutoForme.framework_class_for(type).setup(controller, opts, &block)
12 end
new(controller, opts={})
[show source]
   # File lib/autoforme/framework.rb
45 def initialize(controller, opts={})
46   @controller = controller
47   @opts = opts.dup
48   @prefix = @opts[:prefix]
49   @models = {}
50   @model_classes = {}
51 end
setup(controller, opts, &block)

Setup a new framework class.

[show source]
   # File lib/autoforme/framework.rb
15 def self.setup(controller, opts, &block)
16   f = new(controller, opts)
17   f.model_type :sequel
18   f.instance_exec(&block)
19   f
20 end

Public Instance methods

action_for(request)

Return the action related to the given request, if such an action is supported.

[show source]
    # File lib/autoforme/framework.rb
158 def action_for(request)
159   if model = @models[request.model]
160     action = Action.new(model, request)
161     action if action.supported?
162   end
163 end
autocomplete_options_for(model, type, request)
[show source]
    # File lib/autoforme/framework.rb
113 def autocomplete_options_for(model, type, request)
114   handle_proc(autocomplete_options, model, type, request)
115 end
columns_for(model, type, request)
[show source]
   # File lib/autoforme/framework.rb
65 def columns_for(model, type, request)
66   handle_proc(columns, model, type, request)
67 end
display_name_for(model)
[show source]
   # File lib/autoforme/framework.rb
89 def display_name_for(model)
90   handle_proc(display_name, model)
91 end
edit_html_for(obj, column, type, request)
[show source]
    # File lib/autoforme/framework.rb
125 def edit_html_for(obj, column, type, request)
126   handle_proc(edit_html, obj, column, type, request)
127 end
filter_for(model)
[show source]
   # File lib/autoforme/framework.rb
81 def filter_for(model)
82   handle_proc(filter, model)
83 end
form_attributes_for(model, type, request)
[show source]
   # File lib/autoforme/framework.rb
93 def form_attributes_for(model, type, request)
94   handle_proc(form_attributes, model, type, request) || {}
95 end
form_options_for(model, type, request)
[show source]
   # File lib/autoforme/framework.rb
97 def form_options_for(model, type, request)
98   handle_proc(form_options, model, type, request) || {}
99 end
inline_mtm_associations_for(model, request)
[show source]
   # File lib/autoforme/framework.rb
73 def inline_mtm_associations_for(model, request)
74   handle_proc(inline_mtm_associations, model, request)
75 end
limit_for(model, type, request)
[show source]
   # File lib/autoforme/framework.rb
61 def limit_for(model, type, request)
62   handle_proc(per_page, model, type, request)
63 end
model(model_class, &block)

Add a new model to the existing framework.

[show source]
    # File lib/autoforme/framework.rb
148 def model(model_class, &block)
149   if register_by_name?
150     model_class = model_class.name
151   end
152   model = @model_classes[model_class] = Model.for(self, model_type, model_class, &block)
153   @models[model.link] = model
154 end
model_class(model_class)

Look up the Autoforme::Model class to use for the underlying model class instance.

[show source]
    # File lib/autoforme/framework.rb
140 def model_class(model_class)
141   if register_by_name?
142     model_class = model_class.name
143   end
144   @model_classes[model_class]
145 end
mtm_associations_for(model, request)
[show source]
   # File lib/autoforme/framework.rb
69 def mtm_associations_for(model, request)
70   handle_proc(mtm_associations, model, request)
71 end
order_for(model, type, request)
[show source]
   # File lib/autoforme/framework.rb
77 def order_for(model, type, request)
78   handle_proc(order, model, type, request)
79 end
page_header_for(model, type, request)
[show source]
    # File lib/autoforme/framework.rb
105 def page_header_for(model, type, request)
106   handle_proc(page_header, model, type, request)
107 end
redirect_for(model)
[show source]
   # File lib/autoforme/framework.rb
85 def redirect_for(model)
86   handle_proc(redirect, model)
87 end
register_by_name(register=true)

Set whether to register classes by name instead of by reference

[show source]
    # File lib/autoforme/framework.rb
130 def register_by_name(register=true)
131   opts[:register_by_name] = register
132 end
register_by_name?()

Whether to register classes by name instead of by reference

[show source]
    # File lib/autoforme/framework.rb
135 def register_by_name?
136   opts[:register_by_name]
137 end
show_html_for(obj, column, type, request)
[show source]
    # File lib/autoforme/framework.rb
121 def show_html_for(obj, column, type, request)
122   handle_proc(show_html, obj, column, type, request)
123 end
supported_actions_for(model, request)
[show source]
   # File lib/autoforme/framework.rb
53 def supported_actions_for(model, request)
54   handle_proc(supported_actions, model, request)
55 end
table_class_for(model, type, request)
[show source]
   # File lib/autoforme/framework.rb
57 def table_class_for(model, type, request)
58   handle_proc(table_class, model, type, request)
59 end