Class: OmniContacts::Builder
- Inherits:
-
Rack::Builder
- Object
- Rack::Builder
- OmniContacts::Builder
- Defined in:
- lib/omnicontacts/builder.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
- #importer(importer, *args) ⇒ Object
-
#initialize(app, &block) ⇒ Builder
constructor
A new instance of Builder.
- #rack14? ⇒ Boolean
Constructor Details
#initialize(app, &block) ⇒ Builder
Returns a new instance of Builder.
5 6 7 8 9 10 11 12 |
# File 'lib/omnicontacts/builder.rb', line 5 def initialize(app, &block) if rack14? super else @app = app super(&block) end end |
Instance Method Details
#call(env) ⇒ Object
26 27 28 29 |
# File 'lib/omnicontacts/builder.rb', line 26 def call env @ins << @app unless rack14? || @ins.include?(@app) to_app.call(env) end |
#importer(importer, *args) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/omnicontacts/builder.rb', line 19 def importer importer, *args middleware = OmniContacts::Importer.const_get(importer.to_s.capitalize) use middleware, *args rescue NameError raise LoadError, "Could not find importer #{importer}." end |
#rack14? ⇒ Boolean
14 15 16 17 |
# File 'lib/omnicontacts/builder.rb', line 14 def rack14? v = Rack.release.split('.') v[0].to_i >= 1 || v[1].to_i >= 4 end |