Class: PostDecorator
- Inherits:
-
Sinatra::Decorator::Base
- Object
- Sinatra::Decorator::Base
- PostDecorator
show all
- Includes:
- FluentdServer::WebHelper
- Defined in:
- lib/fluentd_server/decorator.rb
Instance Method Summary
collapse
#active_if, #bootstrap_flash, #disabled_if, #escape_url, #parse_query, #url_for
Instance Method Details
28
29
30
31
32
|
# File 'lib/fluentd_server/decorator.rb', line 28
def create_button
%Q[<div style="padding: 0 0 10px 10px;font-variant:small-caps;">
<a class="btn btn-default #{active_if(self.new?)}" role="button"
href="/posts/create">Create Config</a></div>]
end
|
#error_message ⇒ Object
11
12
13
14
15
|
# File 'lib/fluentd_server/decorator.rb', line 11
def error_message
message = 'Failure! '
message += self.errors.map {|key, msg| escape_html("`#{key}` #{msg}") }.join('. ')
message
end
|
#link_to ⇒ Object
22
23
24
25
26
|
# File 'lib/fluentd_server/decorator.rb', line 22
def link_to
%Q[<a href="#{h("/posts/#{self.id}/edit")}">
<span class="label label-success"> </span> ##{h(self.id)} #{h(self.name)}
</a>]
end
|
#render_body(locals) ⇒ Object
17
18
19
20
|
# File 'lib/fluentd_server/decorator.rb', line 17
def render_body(locals)
namespace = OpenStruct.new(locals)
ERB.new(self.body, nil, "-").result(namespace.instance_eval { binding })
end
|
#success_message ⇒ Object
7
8
9
|
# File 'lib/fluentd_server/decorator.rb', line 7
def success_message
'Success!'
end
|