sandyw-active_configuration 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
@@ -6,12 +6,12 @@ module ActiveConfiguration
|
|
6
6
|
# when the #configure block is used on an ActiveRecord model. For more details
|
7
7
|
# see ActiveRecord::Configuration#configure.
|
8
8
|
class Base
|
9
|
-
attr_accessor :
|
9
|
+
attr_accessor :options_hash
|
10
10
|
|
11
11
|
# Initializes an empty options hash to store ActiveConfiguration::Option
|
12
12
|
# instances containing configuration details.
|
13
13
|
def initialize
|
14
|
-
@
|
14
|
+
@options_hash = HashWithIndifferentAccess.new
|
15
15
|
end
|
16
16
|
|
17
17
|
# Creates and accepts the configuration details for an Option.
|
@@ -32,11 +32,12 @@ module ActiveConfiguration
|
|
32
32
|
def option(key, &block)
|
33
33
|
opt = Option.new(key)
|
34
34
|
opt.instance_eval(&block)
|
35
|
-
@
|
35
|
+
@options_hash[key.to_sym] = opt
|
36
36
|
end
|
37
37
|
|
38
38
|
def options( namespace = nil )
|
39
|
-
@
|
39
|
+
return @options_hash if namespace == :all
|
40
|
+
@options_hash.select{|key, option| option.option_namespace == namespace }.with_indifferent_access
|
40
41
|
end
|
41
42
|
end
|
42
43
|
end
|
@@ -24,7 +24,7 @@ module ActiveConfiguration
|
|
24
24
|
# @return [Hash, Array, NilClass] the Hash or Array of Hashes for the
|
25
25
|
# setting with the given key or nil if there isn't a match.
|
26
26
|
def [](key)
|
27
|
-
if @configurable.class.configuration.
|
27
|
+
if @configurable.class.configuration.options_hash.has_key?(key)
|
28
28
|
@settings[key] ||= SettingProxy.new(self, key)
|
29
29
|
|
30
30
|
return @settings[key].value
|
@@ -41,7 +41,7 @@ module ActiveConfiguration
|
|
41
41
|
# @return [Hash, Array, NilClass] the Hash or Array of Hashes for the
|
42
42
|
# setting with the given key or nil if there isn't a match.
|
43
43
|
def []=(key, value)
|
44
|
-
if @configurable.class.configuration.
|
44
|
+
if @configurable.class.configuration.options_hash.has_key?(key)
|
45
45
|
@settings[key] ||= SettingProxy.new(self, key)
|
46
46
|
@settings[key].replace(value)
|
47
47
|
|
@@ -91,4 +91,4 @@ module ActiveConfiguration
|
|
91
91
|
@settings = Hash.new
|
92
92
|
end
|
93
93
|
end
|
94
|
-
end
|
94
|
+
end
|
@@ -177,7 +177,7 @@ module ActiveConfiguration
|
|
177
177
|
#
|
178
178
|
# @return [ActiveConfiguration::Option] the option for this setting.
|
179
179
|
def option
|
180
|
-
return @manager.configurable.class.configuration.
|
180
|
+
return @manager.configurable.class.configuration.options_hash[key]
|
181
181
|
end
|
182
182
|
|
183
183
|
# Coerces a stored String value into the expected type if an allowed format
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sandyw-active_configuration
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -196,7 +196,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
196
196
|
version: '0'
|
197
197
|
segments:
|
198
198
|
- 0
|
199
|
-
hash:
|
199
|
+
hash: -3189903809501531503
|
200
200
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
201
201
|
none: false
|
202
202
|
requirements:
|