flarg 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.md +34 -0
- data/lib/flarg.rb +0 -1
- data/lib/flarg/railtie.rb +2 -0
- data/lib/flarg/version.rb +1 -1
- metadata +1 -1
data/README.md
CHANGED
@@ -0,0 +1,34 @@
|
|
1
|
+
# Flarg
|
2
|
+
|
3
|
+
Adds a class to your ralis app that stores configuration variables.
|
4
|
+
|
5
|
+
[![Build Status](https://secure.travis-ci.org/brundage/flarg.png)](http://travis-ci.org/brundage/flarg)
|
6
|
+
[![Dependency Status](https://gemnasium.com/brundage/flarg.png)](https://gemnasium.com/brundage/flarg)
|
7
|
+
|
8
|
+
## WTF?
|
9
|
+
|
10
|
+
> Isn't there a `Rails.application.config`?
|
11
|
+
|
12
|
+
Yes, and this gem uses it so you can do:
|
13
|
+
|
14
|
+
# config/initializers/some_initializer.rb
|
15
|
+
|
16
|
+
MyKeenAppConfig.configure do |config|
|
17
|
+
|
18
|
+
config.use_recursive_sql = Rails.application.config.database_configuration[Rails.env]["adapter"] == "postgresql"
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
Then in your app somewhere:
|
23
|
+
|
24
|
+
class Thing < ActiveRecord::Base
|
25
|
+
|
26
|
+
def ancestors
|
27
|
+
if MyKeenAppConfig.config.use_recursive_sql
|
28
|
+
self.class.find_by_sql(%Q^ WITH RECURSIVE parents AS ( SELECT .... )^)
|
29
|
+
else
|
30
|
+
Rails.logger.debug("Recursive SQL not supported by this database")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
Flarg namespaces keys in `Rails.application.config` so you don't have to!
|
data/lib/flarg.rb
CHANGED
data/lib/flarg/railtie.rb
CHANGED
data/lib/flarg/version.rb
CHANGED