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.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/autoforme/frameworks/roda.rb', line 48 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 r.env['SCRIPT_NAME'] 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 view(:content=>@autoforme_text) end end end end |
Instance Attribute Details
#route_proc ⇒ Object (readonly)
Returns the value of attribute route_proc.
44 45 46 |
# File 'lib/autoforme/frameworks/roda.rb', line 44 def route_proc @route_proc end |