Class: PostDecorator

Inherits:
Sinatra::Decorator::Base
  • Object
show all
Includes:
FluentdServer::WebHelper
Defined in:
lib/fluentd_server/decorator.rb

Instance Method Summary collapse

Methods included from FluentdServer::WebHelper

#active_if, #bootstrap_flash, #disabled_if, #escape_url, #parse_query, #url_for

Instance Method Details

#create_buttonObject



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_messageObject



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


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">&nbsp;</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_messageObject



7
8
9
# File 'lib/fluentd_server/decorator.rb', line 7

def success_message
  'Success!'
end