Class: AutoForme::Frameworks::Roda

Inherits:
AutoForme::Framework show all
Defined in:
lib/autoforme/frameworks/roda.rb

Defined Under Namespace

Classes: Request

Instance Attribute Summary collapse

Attributes inherited from AutoForme::Framework

#controller, #model_classes, #models, #opts, #prefix

Instance Method Summary collapse

Methods inherited from AutoForme::Framework

#action_for, #association_links_for, #autocomplete_options_for, #columns_for, #display_name_for, #filter_for, for, #form_attributes_for, #form_options_for, #inline_mtm_associations_for, #lazy_load_association_links?, #limit_for, #model, #mtm_associations_for, #order_for, #page_footer_for, #page_header_for, #redirect_for, setup, #supported_actions_for, #table_class_for

Methods included from OptsAttributes

#opts_attribute

Constructor Details

#initializeRoda

Return a proc that should be instance_execed in the Roda routing and and handles the route if it recognizes it, otherwise doing nothing.



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/autoforme/frameworks/roda.rb', line 39

def initialize(*)
  super
  framework = self

  matchers = [:model, :action_type]
  if framework.prefix
    matchers.unshift(framework.prefix[1..-1])
  end

  @route_proc = lambda do 
    r = request
    path = r.env['SCRIPT_NAME']
    current_matchers = matchers.dup
    current_matchers << lambda do
      @autoforme_action = framework.action_for(Request.new(self, path))
    end

    r.on *current_matchers do
      @autoforme_text = @autoforme_action.handle
      opts = {:content=>@autoforme_text}
      opts[:layout] = false if @autoforme_action.request.xhr?
      view opts
    end
  end
end

Instance Attribute Details

#route_procObject (readonly)

Returns the value of attribute route_proc.



35
36
37
# File 'lib/autoforme/frameworks/roda.rb', line 35

def route_proc
  @route_proc
end