Class: FluffyBarbarian::Application

Inherits:
Object
  • Object
show all
Includes:
Rack::Utils
Defined in:
lib/fluffy_barbarian/application.rb

Instance Method Summary collapse

Instance Method Details

#content_dirObject



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)

Returns:

  • (Boolean)


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

#layoutObject



47
# File 'lib/fluffy_barbarian/application.rb', line 47

def layout; "layout"; end

#production?Boolean

Returns:

  • (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
    options = args.first
    t = options.delete(:template)
  else
    t = args.shift
    options = args.shift || {}
  end
  c = options.delete(:content)
  l = options.has_key?(:layout) ? options.delete(:layout) : layout

  locals = options.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_dirObject



45
# File 'lib/fluffy_barbarian/application.rb', line 45

def template_dir; "templates"; end