Class: AutoForme::Frameworks::Roda
- Inherits:
-
AutoForme::Framework
- Object
- AutoForme::Framework
- AutoForme::Frameworks::Roda
- Defined in:
- lib/autoforme/frameworks/roda.rb
Defined Under Namespace
Classes: Request
Instance Attribute Summary collapse
-
#route_proc ⇒ Object
readonly
Returns the value of attribute route_proc.
Attributes inherited from AutoForme::Framework
#controller, #model_classes, #models, #opts, #prefix
Instance Method Summary collapse
-
#initialize ⇒ Roda
constructor
Return a proc that should be instance_execed in the Roda routing and and handles the route if it recognizes it, otherwise doing nothing.
Methods inherited from AutoForme::Framework
#action_for, #association_links_for, #autocomplete_options_for, #columns_for, #display_name_for, #edit_html_for, #filter_for, for, #form_attributes_for, #form_options_for, #inline_mtm_associations_for, #lazy_load_association_links?, #limit_for, #model, #model_class, #mtm_associations_for, #order_for, #page_footer_for, #page_header_for, #redirect_for, #register_by_name, #register_by_name?, setup, #show_html_for, #supported_actions_for, #table_class_for
Methods included from OptsAttributes
Constructor Details
#initialize ⇒ Roda
Return a proc that should be instance_execed in the Roda routing and and handles the route if it recognizes it, otherwise doing nothing.
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/autoforme/frameworks/roda.rb', line 88 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 = if r.respond_to?(:matched_path) r.matched_path else # :nocov: r.env['SCRIPT_NAME'] # :nocov: end current_matchers = matchers + [lambda{@autoforme_action = framework.action_for(Request.new(self, path))}] r.on(*current_matchers) do @autoforme_text = @autoforme_action.handle if @autoforme_action.output_type == 'csv' response['Content-Type'] = 'text/csv' response['Content-Disposition'] = "attachment; filename=#{@autoforme_action.output_filename}" @autoforme_text elsif @autoforme_action.request.xhr? @autoforme_text else opts = framework.opts[:view_options] opts = opts ? opts.dup : {} opts[:content] = @autoforme_text view(opts) end end end end |
Instance Attribute Details
#route_proc ⇒ Object (readonly)
Returns the value of attribute route_proc.
84 85 86 |
# File 'lib/autoforme/frameworks/roda.rb', line 84 def route_proc @route_proc end |