Module: Bizside::Configurations::Prefix

Included in:
Bizside::Config
Defined in:
lib/bizside/configurations/prefix.rb

Instance Method Summary collapse

Instance Method Details

#prefix(ending_slash = false) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/bizside/configurations/prefix.rb', line 5

def prefix(ending_slash = false)
  ret = ENV['X-BIZSIDE-PREFIX']

  if ret.to_s.empty?
    ret = self.prefix? ? self['prefix'] : '/'
  end

  if ret != '/'
    if ending_slash
      ret = ret + '/' unless ret.end_with?('/')
    else
      ret = ret[0..-2] if ret.end_with?('/')
    end
  end
  
  ret
end