breadboard 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -1 +1,53 @@
1
- breadboard.yml is to ActiveResource as database.yml is to ActiveRecord
1
+ =Introduction
2
+
3
+ breadboard.yml is to ActiveResource as database.yml is to ActiveRecord. If you have the situation where the services you connect your ActiveResource models to depends on your RAILS environment, then breadboard is for you.
4
+
5
+ =Install
6
+
7
+ Breadboard is available as a gem:
8
+
9
+ # gem install breadboard
10
+
11
+ If you'd like to use this in your rails project, add the following to your config/environment.rb:
12
+
13
+ config.gem 'breadboard'
14
+
15
+ =Usage
16
+
17
+ All you have to do is create a breadboard.yml file in your RAILS_ROOT/config directory.
18
+
19
+ In the simplest scenario, all of your ActiveResource models connect to the same service provider in all environments. In this case, you really don't need this gem, but if you're determined to use it just because you know it's the coolest thing ever, then we've got you covered:
20
+
21
+ default:
22
+ all: http://my.universal.service.provider.com
23
+
24
+ This means: for all ActiveResource models, in all environments, connect them to http://my.universal.service.provider.com
25
+
26
+ However, it's more likely that you're using this gem because you are in a situation where you need to connect your models to different services based on a rails environment. This is also trivial with breadboard:
27
+
28
+ default:
29
+ production: http://my.production.service.provider.com
30
+ development: http://my.development.service.provider
31
+
32
+ Now suppose you have an 'Author' model that needs to connect to a completely different service from everything else, in all environments:
33
+
34
+ default:
35
+ production: http://my.production.service.provider.com
36
+ development: http://my.development.service.provider
37
+
38
+ author:
39
+ all: http://my.author.service.prodiver
40
+
41
+ Now suppose you have a 'Book' model that needs to connect to a different service provider than the default when in 'production' mode:
42
+
43
+ default:
44
+ production: http://my.production.service.provider.com
45
+ development: http://my.development.service.provider
46
+
47
+ author:
48
+ all: http://my.author.service.prodiver
49
+
50
+ book:
51
+ production: http://my.book.production.service.provider
52
+
53
+ I think you can see where this is going...
@@ -29,7 +29,7 @@ class Breadboard
29
29
  def configure_services
30
30
  classes = ActiveResource::Base.send(:subclasses)
31
31
  classes.each do |klass|
32
- klass.constantize.site = service_for(klass)
32
+ klass.constantize.site = service_for(klass) if klass.constantize.site == nil
33
33
  end
34
34
  end
35
35
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: breadboard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Parker