setler 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
data/contributors.txt CHANGED
@@ -2,3 +2,4 @@ Chris Kelly github.com/ckdake
2
2
  Andy Lindeman github.com/alindeman
3
3
  Phil Ostler github.com/philostler
4
4
  Rachel Heaton github.com/rheaton
5
+ Corey Innis github.com/coreyti
@@ -1,7 +1,7 @@
1
1
  module Setler
2
2
  class ScopedSettings < Settings
3
3
  def self.for_thing(object, scopename)
4
- set_table_name scopename
4
+ self.table_name = scopename
5
5
  @object = object
6
6
  self
7
7
  end
@@ -3,8 +3,9 @@ module Setler
3
3
  serialize :value
4
4
  self.abstract_class = true
5
5
 
6
- cattr_accessor :defaults
7
- @@defaults = {}.with_indifferent_access
6
+ def self.defaults
7
+ @defaults ||= {}.with_indifferent_access
8
+ end
8
9
 
9
10
  # Get and Set variables when the calling method is the variable name
10
11
  def self.method_missing(method, *args, &block)
@@ -22,7 +23,7 @@ module Setler
22
23
 
23
24
  def self.[](var)
24
25
  the_setting = thing_scoped.find_by_var(var.to_s)
25
- the_setting.present? ? the_setting.value : @@defaults[var]
26
+ the_setting.present? ? the_setting.value : defaults[var]
26
27
  end
27
28
 
28
29
  def self.[]=(var, value)
@@ -48,7 +49,7 @@ module Setler
48
49
  end
49
50
 
50
51
  def self.all
51
- @@defaults.merge(Hash[thing_scoped.all.collect{ |s| [s.var, s.value] }])
52
+ defaults.merge(Hash[thing_scoped.all.collect{ |s| [s.var, s.value] }])
52
53
  end
53
54
 
54
55
  def self.thing_scoped
@@ -1,3 +1,3 @@
1
1
  module Setler
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
@@ -114,7 +114,7 @@ class ::SettingsTest < Test::Unit::TestCase
114
114
  def test_user_settings_all
115
115
  ::Settings.destroy_all
116
116
  user = User.create name: 'user 1'
117
- assert_equal ::Settings.all, user.preferences.all
117
+ assert_equal ::Preferences.all, user.preferences.all
118
118
  user.preferences.likes_bacon = true
119
119
  user.preferences.really_likes_bacon = true
120
120
  assert user.preferences.all['likes_bacon']
@@ -146,4 +146,16 @@ class ::SettingsTest < Test::Unit::TestCase
146
146
  ::Settings.destroy :not_a_setting
147
147
  end
148
148
  end
149
+
150
+ def test_implementations_are_independent
151
+ ::Preferences.create(:var => 'test', :value => 'preferences foo')
152
+ ::Preferences.create(:var => 'test2', :value => 'preferences bar')
153
+
154
+ assert_not_equal ::Settings.defaults, ::Preferences.defaults
155
+
156
+ assert_equal 'foo', ::Settings[:test]
157
+ assert_equal 'bar', ::Settings[:test2]
158
+ assert_equal 'preferences foo', ::Preferences[:test]
159
+ assert_equal 'preferences bar', ::Preferences[:test2]
160
+ end
149
161
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: setler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-24 00:00:00.000000000Z
12
+ date: 2012-06-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
16
- requirement: &70289506810140 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: 3.0.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70289506810140
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 3.0.0
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: rails
27
- requirement: &70289506809640 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: 3.0.0
33
38
  type: :runtime
34
39
  prerelease: false
35
- version_requirements: *70289506809640
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 3.0.0
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: sqlite3
38
- requirement: &70289506809260 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ! '>='
@@ -43,10 +53,15 @@ dependencies:
43
53
  version: '0'
44
54
  type: :development
45
55
  prerelease: false
46
- version_requirements: *70289506809260
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: rake
49
- requirement: &70289506808800 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
67
  - - ! '>='
@@ -54,10 +69,15 @@ dependencies:
54
69
  version: '0'
55
70
  type: :development
56
71
  prerelease: false
57
- version_requirements: *70289506808800
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
58
78
  - !ruby/object:Gem::Dependency
59
79
  name: cover_me
60
- requirement: &70289506808380 !ruby/object:Gem::Requirement
80
+ requirement: !ruby/object:Gem::Requirement
61
81
  none: false
62
82
  requirements:
63
83
  - - ! '>='
@@ -65,7 +85,12 @@ dependencies:
65
85
  version: '0'
66
86
  type: :development
67
87
  prerelease: false
68
- version_requirements: *70289506808380
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
69
94
  description: Setler is a Gem that lets one easily implement the "Feature Flags" pattern,
70
95
  or add settings to individual models. This is a cleanroom implementation of what
71
96
  the 'rails-settings' gem does. It's been forked all over the place, and my favorite
@@ -116,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
141
  version: '0'
117
142
  requirements: []
118
143
  rubyforge_project: setler
119
- rubygems_version: 1.8.6
144
+ rubygems_version: 1.8.24
120
145
  signing_key:
121
146
  specification_version: 3
122
147
  summary: Settler lets you use the 'Feature Flags' pettern or add settings to models.