Module: Apicraft::Web::Actions
- Defined in:
- lib/apicraft/web/actions.rb
Overview
Web actions to be handled from the rack app.
Class Method Summary collapse
- .contract(view_path) ⇒ Object
- .images(view_path) ⇒ Object
- .mime_type(view_path) ⇒ Object
- .render_erb(view_path) ⇒ Object
Class Method Details
.contract(view_path) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/apicraft/web/actions.rb', line 30 def self.contract(view_path) [ File.read(view_path), MIME::Types.type_for(view_path)[0].to_s ] end |
.images(view_path) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/apicraft/web/actions.rb', line 23 def self.images(view_path) [ File.read(view_path), mime_type(view_path) ] end |
.mime_type(view_path) ⇒ Object
37 38 39 40 |
# File 'lib/apicraft/web/actions.rb', line 37 def self.mime_type(view_path) ext = File.extname(view_path) Rack::Mime.mime_type(ext) end |
.render_erb(view_path) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/apicraft/web/actions.rb', line 8 def self.render_erb(view_path) @vars = { urls: Router.contract_urls, namespace: Router.namespace, version: Apicraft::VERSION } [ ERB.new( File.read(view_path) ).result(binding), "text/html" ] end |