Class: Warbler::Traits::War::WebxmlOpenStruct
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- Warbler::Traits::War::WebxmlOpenStruct
- Defined in:
- lib/warbler/traits/war.rb
Overview
Helper class for holding arbitrary config.webxml values for injecting into web.xml
.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #context_params(escape = true) ⇒ Object
-
#initialize(key = 'webxml') ⇒ WebxmlOpenStruct
constructor
A new instance of WebxmlOpenStruct.
- #servlet_context_listener ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(key = 'webxml') ⇒ WebxmlOpenStruct
Returns a new instance of WebxmlOpenStruct.
177 178 179 180 |
# File 'lib/warbler/traits/war.rb', line 177 def initialize(key = 'webxml') @key = key @table = Hash.new { |h, k| h[k] = WebxmlOpenStruct.new(k) } end |
Instance Method Details
#[](key) ⇒ Object
193 194 195 196 |
# File 'lib/warbler/traits/war.rb', line 193 def [](key) new_ostruct_member(key) send(key) end |
#[]=(key, value) ⇒ Object
198 199 200 201 |
# File 'lib/warbler/traits/war.rb', line 198 def []=(key, value) new_ostruct_member(key) send("#{key}=", value) end |
#context_params(escape = true) ⇒ Object
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
# File 'lib/warbler/traits/war.rb', line 203 def context_params(escape = true) require 'cgi' params = {} @table.each do |k,v| case v when WebxmlOpenStruct nested_params = v.context_params nested_params.each do |nk,nv| params["#{escape ? CGI::escapeHTML(k.to_s) : k.to_s}.#{nk}"] = nv end else params[escape ? CGI::escapeHTML(k.to_s) : k.to_s] = escape ? CGI::escapeHTML(v.to_s) : v.to_s end end extra_ignored = Array === ignored ? ignored : [] params.delete_if {|k,v| ['ignored', *extra_ignored].include?(k.to_s) } params end |
#servlet_context_listener ⇒ Object
182 183 184 185 186 187 188 189 190 191 |
# File 'lib/warbler/traits/war.rb', line 182 def servlet_context_listener case self.booter when :rack "org.jruby.rack.RackServletContextListener" when :merb "org.jruby.rack.merb.MerbServletContextListener" else # :rails, default "org.jruby.rack.rails.RailsServletContextListener" end end |
#to_s ⇒ Object
222 223 224 |
# File 'lib/warbler/traits/war.rb', line 222 def to_s "No value for '#@key' found" end |