opinionated 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/opinionated.rb +20 -1
- metadata +4 -4
data/lib/opinionated.rb
CHANGED
@@ -28,7 +28,7 @@ module Reamaze
|
|
28
28
|
raise ArgumentError, "#{self} class already preferences :#{preferential} defined" if self.preferential_configuration.has_key?(preferential)
|
29
29
|
|
30
30
|
configuration = Configuration.new(self, preferential, options)
|
31
|
-
yield configuration
|
31
|
+
yield configuration if block_given?
|
32
32
|
preferential_configuration[preferential] = configuration
|
33
33
|
|
34
34
|
# override hstore Hash with a custom Hash
|
@@ -43,6 +43,25 @@ module Reamaze
|
|
43
43
|
EOS
|
44
44
|
)
|
45
45
|
end
|
46
|
+
|
47
|
+
# add form accessible attributes
|
48
|
+
configuration.definitions.values.each do |definition|
|
49
|
+
class_eval do
|
50
|
+
eval(
|
51
|
+
<<-EOS
|
52
|
+
def #{preferential}_#{definition.name}=(value)
|
53
|
+
set_preferential('#{preferential}', '#{definition.name}', value, true)
|
54
|
+
end
|
55
|
+
def #{preferential}_#{definition.name}
|
56
|
+
get_preferential('#{preferential}', '#{definition.name}', true)
|
57
|
+
end
|
58
|
+
def #{preferential}_#{definition.name}?
|
59
|
+
!!get_preferential('#{preferential}', '#{definition.name}', true)
|
60
|
+
end
|
61
|
+
EOS
|
62
|
+
)
|
63
|
+
end
|
64
|
+
end
|
46
65
|
end
|
47
66
|
end
|
48
67
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opinionated
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Lu Wang
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-10-22 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: rails
|