Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

now we rename default_app to default_engine, and `run' would set @engine

  • Loading branch information...
commit 7895f4c2b4e138c659ce501032840420467aa773 1 parent e00e95e
Lin Jen-Shin (godfat) godfat authored
1  CHANGES.md
View
@@ -89,6 +89,7 @@ It's a bit outdated, but you can also checkout my blog post.
* [EmHttpRequestFiber] is removed in favor of `EmHttpRequest`
* cool.io support is removed.
* You must provide a block to `app.call(env){ ... }`.
+* Rename Wrapper#default_app to Wrapper#default_engine
### Enhancement
4 lib/rest-core/builder.rb
View
@@ -6,8 +6,8 @@ class RestCore::Builder
include RestCore
include Wrapper
- def self.default_app
- @default_app ||= RestCore::Auto
+ def self.default_engine
+ @default_engine ||= RestCore::Auto
end
def self.client *attrs, &block
30 lib/rest-core/wrapper.rb
View
@@ -4,38 +4,38 @@
module RestCore::Wrapper
include RestCore
- module DefaultApp
- def default_app
- @default_app ||= RestCore::Dry
+ module DefaultEngine
+ def default_engine
+ @default_engine ||= RestCore::Dry
end
end
def self.included mod
- mod.send(:extend, DefaultApp)
+ mod.send(:extend, DefaultEngine)
class << mod
- attr_writer :default_app
+ attr_writer :default_engine
end
end
- attr_reader :init, :middles, :wrapped
- attr_writer :default_app
- def default_app
- @default_app ||= self.class.default_app
+ attr_reader :middles, :wrapped
+ attr_writer :default_engine
+ def default_engine
+ @default_engine ||= self.class.default_engine
end
def initialize &block
@middles ||= []
instance_eval(&block) if block_given?
@wrapped ||= to_app
- @init = nil
+ @engine = nil
end
def use middle, *args, &block
middles << [middle, args, block]
end
- def run app
- @init = app
+ def run engine
+ @engine = engine
end
def members
@@ -49,11 +49,11 @@ def members
}.flatten.compact
end
- def to_app app=init || default_app
+ def to_app engine=@engine || default_engine
# === foldr m.new app middles
- middles.reverse.inject(app.new){ |app_, (middle, args, block)|
+ middles.reverse.inject(engine.new){ |app, (middle, args, block)|
begin
- middle.new(app_, *partial_deep_copy(args), &block)
+ middle.new(app, *partial_deep_copy(args), &block)
rescue ArgumentError => e
raise ArgumentError.new("#{middle}: #{e}")
end
4 test/test_builder.rb
View
@@ -6,9 +6,9 @@
RC::Builder.client.new.app.class.should.eq RC::Auto
end
- should 'switch default_app to RestCore::Dry' do
+ should 'switch default_engine to RestCore::Dry' do
builder = RC::Builder.dup
- builder.default_app = RC::Dry
+ builder.default_engine = RC::Dry
builder.client.new.app.class.should.eq RC::Dry
end
end
4 test/test_wrapper.rb
View
@@ -21,10 +21,10 @@
wrapper.new.wrapped.class.should.eq RC::Dry
end
- should 'switch default_app to RestCore::RestClient' do
+ should 'switch default_engine to RestCore::RestClient' do
wrapper = Class.new
wrapper.send(:include, RC::Wrapper)
- wrapper.default_app = RC::RestClient
+ wrapper.default_engine = RC::RestClient
wrapper.new.wrapped.class.should.eq RC::RestClient
end
Please sign in to comment.
Something went wrong with that request. Please try again.