Class: FluffyBarbarian::Application
- Inherits:
-
Object
- Object
- FluffyBarbarian::Application
- Includes:
- Rack::Utils
- Defined in:
- lib/fluffy_barbarian/application.rb
Instance Method Summary collapse
- #content_dir ⇒ Object
-
#development? ⇒ Boolean
set this much lower if you’re not on heroku (i.e. if you don’t have a reverse proxy) expires(60*60*24*10, :public).
- #guess_file(dir, path) ⇒ Object
- #layout ⇒ Object
- #production? ⇒ Boolean
- #render(*args) ⇒ Object
- #template_dir ⇒ Object
Instance Method Details
#content_dir ⇒ Object
46 |
# File 'lib/fluffy_barbarian/application.rb', line 46 def content_dir; "content"; end |
#development? ⇒ Boolean
set this much lower if you’re not on heroku
(i.e. if you don't have a reverse proxy)
expires(60*60*24*10, :public)
37 38 39 |
# File 'lib/fluffy_barbarian/application.rb', line 37 def development? ENV['RACK_ENV'] == 'development' end |
#guess_file(dir, path) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/fluffy_barbarian/application.rb', line 74 def guess_file(dir, path) dir = dir.to_s path = path.to_s return path if File.exists? path path = File.join(dir, path) return path if File.exists? path return Dir["#{path}*"].first end |
#layout ⇒ Object
47 |
# File 'lib/fluffy_barbarian/application.rb', line 47 def layout; "layout"; end |
#production? ⇒ Boolean
41 42 43 |
# File 'lib/fluffy_barbarian/application.rb', line 41 def production? ENV['RACK_ENV'] == 'production' end |
#render(*args) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/fluffy_barbarian/application.rb', line 49 def render(*args) if args.first.is_a? Hash = args.first t = .delete(:template) else t = args.shift = args.shift || {} end c = .delete(:content) l = .has_key?(:layout) ? .delete(:layout) : layout locals = .delete(:locals) || locals || {} if t output = Tilt.new(guess_file(template_dir, t)).render(self, locals) output = Tilt.new(guess_file(template_dir, l)).render(self, locals) { output } if l elsif c output = Tilt.new(guess_file(content_dir, c)).render(self, locals) else raise ArgumentError end output end |
#template_dir ⇒ Object
45 |
# File 'lib/fluffy_barbarian/application.rb', line 45 def template_dir; "templates"; end |