Class: Bonanza::LinkStrategies::Base
- Inherits:
-
Object
- Object
- Bonanza::LinkStrategies::Base
show all
- Includes:
- ActionView::Helpers::OutputSafetyHelper
- Defined in:
- lib/bonanza/link_strategies/base.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(entity = nil) ⇒ Base
Returns a new instance of Base.
11
12
13
|
# File 'lib/bonanza/link_strategies/base.rb', line 11
def initialize(entity = nil)
@entity = entity.to_s
end
|
Instance Attribute Details
#entity ⇒ Object
Returns the value of attribute entity.
9
10
11
|
# File 'lib/bonanza/link_strategies/base.rb', line 9
def entity
@entity
end
|
Instance Method Details
#app ⇒ Object
15
16
17
|
# File 'lib/bonanza/link_strategies/base.rb', line 15
def app
self.class.name.demodulize.downcase
end
|
#domain ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/bonanza/link_strategies/base.rb', line 23
def domain
case environment.to_s
when 'development'
"http://#{app}.dev"
when 'test'
"http://#{app}.test"
when 'staging'
"https://#{app}-staging.nine.ch"
when 'production'
"https://#{app}.nine.ch"
end
end
|
#environment ⇒ Object
40
41
42
|
# File 'lib/bonanza/link_strategies/base.rb', line 40
def environment
ENV.fetch('RAILS_ENV', 'production')
end
|
#paths ⇒ Object
19
20
21
|
# File 'lib/bonanza/link_strategies/base.rb', line 19
def paths
{}
end
|
#url_to(entity, reference = nil) ⇒ Object
36
37
38
|
# File 'lib/bonanza/link_strategies/base.rb', line 36
def url_to(entity, reference = nil)
raw [domain, paths[entity]].join % { reference: reference }
end
|